When I am logged in as the same user
as the server, I can Enter-PSSession
with:
> Enter-PSSession -ConnectionURI http://xxx.xx.xxx.xx:5985
However, when I'm logged in as a different user (on the same machine) and try to Enter-PSSession
with -Credential
parameter:
> Enter-PSSession -ConnectionUri http://xxx.xx.xxx.xx:5985 -Credential user
After I enter the password, I get:
Enter-PSSession : Connecting to remote server xxx.xx.xxx.xx failed with the
following error message : Access is denied. For more information, see the
about_Remote_Troubleshooting Help topic.
At line:1 char:1
+ Enter-PSSession -ConnectionUri http://xxx.xx.xxx.xx:5985 -Credential user
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (http://xxx.xx.xxx.xx:5985/:Uri
) [Enter-PSSession], PSRemotingTransportException
+ FullyQualifiedErrorId : CreateRemoteRunspaceFailed
Best Answer
(1) You can skip the http:// stuff if you're using the default WinRM configuration and instead of:
enter the following:
You can also use the server's DNS name instead of its IP if there's an DNS entry for the system.
(2) By default only members of the administrator group are allowed to connect to PS remoting endpoints. Are you sure your account is a member of that group?
(3) I read somewhere that the -Credential parameter of Enter-PSSession is broken. The workaround is to create the credential object beforehand:
Please try that and report whether it works.
(4) If you are trying to connect to a machine that is not part of your domain you need to add it to the list of trusted computers on the computer you are trying to start the remoting session from:
And you need to explicitly tell enter-pssession which user account on the remote machine will be used: