Reputation: 162
How is it that one Powershell command works on a remote machine but not the other from the same console?
PS C:> Get-Service -Name WinRM -ComputerName win8
Status Name DisplayName
------ ---- -----------
Running WinRM Windows Remote Management (WS-Manag...
PS C:> Get-Counter '\Paging File(*)\% Usage' -ComputerName win8 Get-Counter : Unable to connect to the specified computer or the computer is offline. At line:1 char:1
Upvotes: 0
Views: 273
Reputation: 8367
Get-Service and Get-Counter use a different remoting layer for -ComputerName. Invoke-Command -ComputerName uses the WinRM remoting layer, Get-Service (I believe) is a remote registry call. Get-Counter is a DCOM call, I believe over WMI.
It's a pretty good rule of thumb that if you don't know that a cmdlet with -ComputerName in it is using the PowerShell remoting layer, it's probably not. Many cmdlets had -ComputerName in V1 of PowerShell, and many other remoting layers are more efficient than WinRM, so many -ComputerName parameters use their own layer.
Upvotes: 1