3

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

1 Answer 1

7

(1) You can skip the http:// stuff if you're using the default WinRM configuration and instead of:

Enter-PSSession -ConnectionURI http://xxx.xx.xxx.xx:5985

enter the following:

Enter-PSSession xxx.xx.xx.xx

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:

$cred = Get-Credential

Enter-PSSession XXX.XX.XX.XX -credential $cred

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:

winrm s winrm/config/client '@{TrustedHosts="RemoteComputerName"}'

And you need to explicitly tell enter-pssession which user account on the remote machine will be used:

$Cred = Get-Credential "remotecomputername\username"

Enter-PSSession XXX.XX.XX.XX -Credential $Cred

6
  • Which account you are talking about? Both server (joon) and current logged in accounts are administrator accounts.
    – joon
    Jan 1, 2014 at 12:28
  • I assume both users are AD accounts with local admin privileges, is that correct?
    – megamorf
    Jan 1, 2014 at 12:31
  • Yes it is. Both users are AD accounts with local admin privileges
    – joon
    Jan 1, 2014 at 12:32
  • Please take a look at (3) of my answer.
    – megamorf
    Jan 1, 2014 at 12:42
  • I tried (3), but the result was the same.
    – joon
    Jan 1, 2014 at 13:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .