Allow Enter-PSSession to work from local systems account

2

I have a PowerShell script that creates a Windows PowerShell session (PSSession) on a remote server via Enter-PSSession, both servers are not connected to a DOMAIN. This script is called from a program that is running as a service under the local systems account. For some reason, running the PowerShell script as a local systems account causes the Enter-PSSession to return an error.

For example, when run from a local admin account the following command asks for my password and connects successfully:

Enter-PSSession -ComputerName #### -Credential ####

However, if I run PowerShell using a Local Systems or Network Service account via psexec:

PsExec -i -s powershell.exe
PsExec -i -u "NT AUTHORITY\NetworkService" powershell.exe

Then try the command again it asks for my password and simply returns an error message:

Enter-PSSession : Connecting to remote server #### failed
with the following error message : WinRM cannot process the request. The
following error with errorcode 0x8009030d occurred while using Negotiate
authentication: A specified logon session does not exist. It may already have
been terminated.

Any idea how I can get the Enter-PSSession command to work under a local systems account?

windows-server-2012
powershell
asked on Server Fault Feb 5, 2015 by ADarkDivideGem • edited Feb 11, 2015 by ADarkDivideGem

1 Answer

1

You cannot use Enter-PSSession in a script, it was intended for interactive logons only. Use Invoke-Command instead.

answered on Server Fault Feb 10, 2015 by Colyn1337

User contributions licensed under CC BY-SA 3.0