Author Posts

October 17, 2013 at 10:50 am

I created a simple script to query for Powershell version on a number of remote servers, but it is not working. Here is the error
New-PSSession : [win2k81] Connecting to remote server win2k81 failed with the following error message : The client cannot connect to the destination specified in the
request. Verify that the service on the destination is running and is accepting requests.

My script is the following:

$servers=get-content c:\servers.txt
$s = New-PSSession -ComputerName (Get-Content c:\Servers.txt) -Credential home\administrator -ThrottleLimit 10
Foreach($server in $servers){
$results+=Invoke-Command -Session $s -Computername $server -Scriptblock {$PSVersionTable.psversion} |
Select-Object PSComputerName, Major
$results=export-csv c:\PSVer.csv

October 17, 2013 at 10:57 am

The error indicates that one of the computers (win2k81) you specified could not be contacted. It's possible it does not have Remoting enabled, or that it was not accessible, or that a firewall was blocking the traffic. Pretty much what the error message says.