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
Richard Slater
  • 3,228
  • 2
  • 28
  • 42
m-sharp
  • 111
  • 1
  • 4
  • 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 06: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 "https://4sysops.com/archives/restricting-the-rights-of-powershell-users-with-a-constrained-session-configuration/" – 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

0 Answers0