1

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
  • 1
    1) are your running this in an elevated powershell? 2) what if you add the -credential parameter to invoke-command? – SimonS May 11 '16 at 6:49
  • 1) Yes 2) Adding -credential does not change behavior for both commands – m-sharp May 11 '16 at 15:59
  • It sound like you may have a restricted endpoint established there. You might want to review the failing host to review the get-PSSessionConfiguration to see if how that server is different from the one that's working. Additional info on constrained session configuration can be found here "4sysops.com/archives/…" – Lex May 11 '16 at 17:45
  • @Lex: Get-PSSessionConfiguration shows the same configuration for the admin endpoint on the problem host and working hosts. Any other ideas? Get-Module also returns nothing. Access denied when I try Import-Module. – m-sharp May 15 '16 at 20:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.