Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $message = $null
- $servers = "Server1","Server2","Server3","Server4"
- $jobs =invoke-command -computername $servers -ScriptBlock{get-service} -asjob
- $jobs | wait-job
- foreach($job in $jobs.ChildJobs)
- {
- try{ receive-job $job -keep -erroraction stop}
- catch [Management.Automation.Remoting.PSRemotingTransportException]{$message += "$((($_.Exception.ErrorRecord.Exception.message).split(" "))[4]) - Connection Failed`n"}
- }
- write-host $message
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement