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:
$results=@()
$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