powershell - Test WinRM/WSMan connectivity? -


i'm trying test if winrm works on list of systems; however, can't seem catch/silence error appears when attempt connect system. appears work on 1 system:

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 

but doesn't work on another:

ps c:\users\egr> winrm id -r:system2 wsmanfault     message = winrm cannot process request. following error occured while using kerberos authentication: net work path not found.  possible causes are:   -the user name or password specified invalid.   -kerberos used when no authentication method , no user name specified.   -kerberos accepts domain user names, not local user names.   -the service principal name (spn) remote computer name , port not exist.   -the client , remote computers in different domains , there no trust between 2 domains.  after checking above issues, try following:   -check event viewer events related authentication.   -change authentication method; add destination computer winrm trustedhosts configuration setting or use  https transport.  note computers in trustedhosts list might not authenticated.    -for more information winrm configuration, run following command: winrm config.  error number:  -2147024843 0x80070035 network path not found. 

i've tried surrounding in try/catch block, doesn't seem silence it. attempting run check against these systems determine ones have winrm configured correctly , working; if script keeps outputting text, won't work neatly. there way suppress text, or there better way test winrm connectivity?

you redirect error stream $null , evaluate $lastexitcode detect error:

$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 } 

Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -