2013-08-12 6 views
2

winrm이 시스템 목록에서 작동하는지 테스트하려고합니다. 그러나 나는 시스템에 연결하려고 할 때 나타나는 오류를 잡아 내지 못하는 것 같습니다. 하나의 시스템에서 작동하도록 나타납니다WinRM/WSMan 연결을 테스트 하시겠습니까?

PS C:\Users\Egr> winrm id -r:system1 
IdentifyResponse 
    ProtocolVersion = http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd 
    ProductVendor = Microsoft Corporation 
    ProductVersion = OS: x.x.xxxx SP: x.x Stack: x.x 

하지만 다른 작동하지 않습니다

PS C:\Users\Egr> winrm id -r:system2 
WSManFault 
    Message = WinRM cannot process the request. The following error occured while using Kerberos authentication: The net 
work path was not found. 
Possible causes are: 
    -The user name or password specified are invalid. 
    -Kerberos is used when no authentication method and no user name are specified. 
    -Kerberos accepts domain user names, but not local user names. 
    -The Service Principal Name (SPN) for the remote computer name and port does not exist. 
    -The client and remote computers are in different domains and there is no trust between the two domains. 
After checking for the above issues, try the following: 
    -Check the Event Viewer for events related to authentication. 
    -Change the authentication method; add the destination computer to the WinRM TrustedHosts configuration setting or use 
HTTPS transport. 
Note that computers in the TrustedHosts list might not be authenticated. 
    -For more information about WinRM configuration, run the following command: winrm help config. 

Error number: -2147024843 0x80070035 
The network path was not found. 

내가 try/catch 블록에 주변 시도했지만, 그것은하지 않는 것 그것을 침묵 시키십시오. 이 시스템에 대해 검사를 실행하여 어떤 시스템이 WinRM이 올바르게 구성되어 있고 작동하는지 확인합니다. 그러나 스크립트가이 텍스트를 계속 출력한다면 아주 잘 작동하지 않을 것입니다. 이 텍스트를 숨기는 방법이 있습니까? 아니면 WinRM 연결을 테스트하는 더 좋은 방법이 있습니까?

답변

1

당신은 $null-redirect the error stream$LastExitCode을 평가하는 오류를 감지 할 수있다 :

$rhost = 'system2' 

winrm id -r:$rhost 2>$null 
if ($LastExitCode -eq 0) { 
    Write-Host "$rhost OK" -ForegroundColor green 
} else { 
    Write-Host "$rhost unavailable" -ForegroundColor red 
} 
+0

내가, 감사 오류 스트림을 리디렉션에 대해 알고하지 않았다! – EGr

+0

이 출력을 다른 변수로 보낼 수 있습니까? 나는'winrm id -r : $ rhost 2> $ tempvar'와 같은 일을 시도했으나 $ tempvar는 변하지 않았다. – EGr

+0

리디렉션 연산자가 작동하는 방식이 아니다. '2> $ tempvar'는 에러 스트림을'$ tempvar'에있는 파일 이름으로 리디렉션합니다. 변수에서 오류 스트림을 캡처하려면 @manojlds가 제안한 [여기서] (http://serverfault.com/a/340716)을 시도하십시오. –