Whenever I try to use Invoke, it gives an error saying I can’t connect:
Connecting to remote server kdtict004 failed with the following error message : Unable to connect to the destination specified in the request. Check whether the service
ce is executed at the destination and whether applications are accepted. Read the logs and documentation for the WS-Management service running at the destination (usually is
this IIS or WinRM). If the destination is the WinRM service, run the following command on the destination to analyze and configure the WinRM service: winrm quickconfig. For more i
nformation, see the about_Remote_Troubleshooting Help topic.
+ CategoryInfo : OpenError: (kdtict004:String) [], PSRemotingTransportException
+ FullyQualifiedErrorId : CannotConnect,PSSessionStateBroken
I can’t really individually go and configure every pc, as I have about 1000 to go through.
The ComputerName is just an address. If you don’t have a key - in this case WinRM - you can go to the address, but you will not be able to do anything with what’s at the address.
It’s possible that some of the machines on your network have WinRM enabled. In the thread I linked above there’s a small script that pings machines and checks whether WinRM is enabled. You can perhaps use that as a starting point.
Did you reboot the devices after enabling WinRM? (shouldn’t really be needed, but Windows tends to behave better after a reboot)
What version of Windows (and Powershell) on the devices?
Can you ping the devices?
In the thread I linked above I mentioned that enabling WinRM should open firewall ports in the built-in Windows firewall, but that it can fail. Have you verified that the ports are allowed in the firewall?
Is there a third party firewall installed on the devices?
Is there a Firewall GPO that affects the devices?
Are they on the same VLAN/Subnet as the calling machine?
If not on the same Subnet or VLAN is there an internal firewall blocking communication?
When you say you cannot connect. Do you mean that you can’t run the Invoke-Command that you wished to run in the first place or do they not respond to the Test-WSMan command?
If you have a third party remote control service running on the devices, is it possible that it uses the same port(s) as WinRM?
A WinRm listener can listen two different ways; HTTP or HTTPS. The WinRM port for HTTP is 5985 while the WinRm port for HTTPS is 5986, by default.
HTTP – Port 5985
HTTPS – Port 5986
In that case you would need to tweak both the WinRM listener service and the firewall as well as call the remote commands specifying the non-standard ports. It’s really not recommended and quite a bit of work! Default WinRm Ports and How to Change Them
@Olaf, @laage, I managed to connect to another pc on the network, but when I run the script it gives the HKEY_USERS from the PC that initiated the script and not the remote PC. What do I do?