I have configured WinRM (PowerShell Remoting) on four machines that I administer. On all machines but one I can run both of these commands remotely with no issue. On one cursed machine, Get-Command
does not work remotely, but Get-ChildItem
and other cmdlets work just fine.
This works:
Invoke-Command -ComputerName myhost -ScriptBlock {Get-ChildItem}
I get a wonderful listing of my user directory.
This doesn't work:
Invoke-Command -ComputerName myhost -ScriptBlock {Get-Command}
Access is denied
+ CategoryInfo : NotSpecified: (:) [Get-Command], UnauthorizedAccessException
+ FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.GetCommandCommand
+ PSComputerName : myhost