Speed up remote commands

instead of just executing the remote command, it is good to check if the host is up.When using the invoke-command a simple test-netconnection beforehand.


$temp = Test-NetConnection -computername <computername> -port 5985 -InformationLevel quiet
if ( $temp -eq ‘true’){
invoke-command -ComputerName <computername>-scriptblock {
Get-ChildItem C:\}}
else {
write-host “error”

without the invoke-command a simple ping/test-netconnection is enough.

Leave a Reply

Your email address will not be published.