Search code examples
powershellcross-domainpowershell-remoting

Powershell remoting does not have the correct permissions


On the non-domain server SERVER I have a local administrator account USER.

On the domain client machine I am running as a domain user.

Using the following code I attempt to view all services on SERVER

$cred = Get-Credential "SERVER\USER"
Invoke-Command -ComputerName SERVER -ScriptBlock {Get-Service} -Credential $cred

However, I receive the following error

Cannot open Service Control Manager on computer '.'. This operation might require other privileges. + CategoryInfo : NotSpecified: (:) [Get-Service], InvalidOperationException + FullyQualifiedErrorId : System.InvalidOperationException,Microsoft.PowerShell.Commands.GetServiceCommand

Yet, if I RDP to SERVER as USER, I can manually open a Powershell window and run Get-Service without any issues. What's going on?


Solution

  • When remoting cross-domain, the remote command/session will not run with administrative rights. Even though you're connecting as a local admin, the resulting PSSession will not be elevated.

    To fix this, you need to set the registry key LocalAccountTokenFilterPolicy located in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System to 1. See Microsoft for more details