Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enter-PSSession to remote server fails with “access is denied”

I want to use winrm remote vm, I can connect to the localhost, but I can't connect to the other remote machine, the error is "access is denied".

Please help me. enter image description here

like image 904
Hoi Fong Iam Avatar asked May 19 '16 08:05

Hoi Fong Iam


People also ask

How do I stop entering PSSession?

Description. The Exit-PSSession cmdlet ends interactive sessions that you started by using the Enter-PSSession cmdlet. You can also use the exit keyword to end an interactive session. The effect is the same as using Exit-PSSession .

How do I start a PSSession on a remote computer?

To use the PSSession to interact directly with a remote computer, use the Enter-PSSession cmdlet. For more information, see about_PSSessions. You can run commands on a remote computer without creating a PSSession with the ComputerName parameters of Enter-PSSession or Invoke-Command .

What is enter-PSSession?

The Enter-PSSession cmdlet starts an interactive session with a single remote computer. During the session, the commands that you type run on the remote computer, just as if you were typing directly on the remote computer. You can have only one interactive session at a time.

What is PSSession in PowerShell?

If you use the ComputerName parameter of the Invoke-Command or Enter-PSSession cmdlet to run a remote command or to start an interactive session, PowerShell creates a temporary session on the remote computer and closes the session as soon as the command is complete or as soon as the interactive session ends.


2 Answers

You need to provide -Credential parameter:

Enter-PSSession –ComputerName Server –Credential Domain\UserName
like image 53
Andrey Marchuk Avatar answered Oct 02 '22 18:10

Andrey Marchuk


So I was having the EXACT same issue as this user and found the issue. Basically I was running the commands as my Domain Admin account but the servers are locked down to not accept network connections from Domain Admin accounts in Group Policy as a security measure. Once changing the command credentials to run as my non domain admin account and an account allowed network access with administrative permissions the enter-pssession command worked perfectly. What I don't understand is why the test-wsman command appears to work.

like image 44
Jamie Lawson Avatar answered Oct 02 '22 20:10

Jamie Lawson