Lomlom
Lomlom

Reputation: 3

Enter-PSSession unable to remote into a remote desktop

I am trying to remote into another desktop using Powershell's Enter-PSSession to run a script automatically, however, i am not even able to connect to the remote desktop.

Enter-PSSession -Computername 172.16.164.14 -credential $cred

But it says access is denied. This is the error message:

Enter-PSSession : Connecting to remote server 172.16.164.14 failed with the following error message : Access is denied. For more information, see the about_Remote_Troubleshooting Help topic.

I also tried using:

Invoke-Command -ComputerName 7450-56Z0BP2 -FilePath -C:\user_automation\automate.vbs -credential $cred

where 7450-56Z0BP2 is the hostname, but the error it gave me is:

[7450-56Z0BP2] Connecting to remote server 7450-56Z0BP2 failed with the following error message : WinRM cannot process the request.

I am not sure what could be the cause of me not being able to access the remote computer. I am able to access it via RDP, but I am not able to log in using the powershell script.

Upvotes: 0

Views: 7138

Answers (3)

Amritpal sandhu
Amritpal sandhu

Reputation: 1

You need to enable PowerShell Remoting on Remote Server as Follows:

Allowing remote PowerShell Windows Endpoint access

  1. Open a PowerShell session as Administrator.
  2. Execute the following command to open the PowerShell Endpoint security windows:

Set-PSSessionConfiguration -Name Microsoft.PowerShell -ShowSecurityDescriptorUI -Force

  1. Click Add.
  2. Select the desired user to include to the list.
  3. Enable Read and Execute permissions.
  4. Click OK to apply your change.

Upvotes: 0

henrycarteruk
henrycarteruk

Reputation: 13227

PowerShell Remoting is not Remote Desktop, they are both setup differently, use different components and do not really share any commonality.

Permissions are not linked between the two, just because you can RDP to a computer does not mean you have PSRemoting permissions.

You use PSRemoting you need to run Enable-PSRemoting on the remote machine. This sets up all the requirements: settings, firewall rules and services. This command needs to be run as a user with Administrator permissions on the remote machine.

Once this is setup, you will be able to connect using Enter-PSSession / Invoke-Command


Your code to run a vbscript remotely won't work because the FilePath param is for a PowerShell script. To run a vbscript remotely you need to call cscript:

Invoke-Command -ComputerName '7450-56Z0BP2' -ScriptBlock { cscript.exe "C:\user_automation\automate.vbs" } -Credential $cred

Upvotes: 1

Tomek
Tomek

Reputation: 671

This is permissions problem, not powershell remoting problem. Your error is "access denied"(Your example 1) , not "could not connect".
Essentially being able to log on using remote desktop requires different permissions than being able to use psremoting. Here is how You check on target servers what security group membership will allow You to use psremoting:

PS C:> (Get-PSSessionConfiguration -Name Microsoft.PowerShell).Permission
NT AUTHORITY\INTERACTIVE AccessAllowed, BUILTIN\Administrators AccessAllowed, BUILTIN\Remote Management Users AccessAllo
wed

While remote desktop is granted by being a member of Remote Desktop Users group or local administrators group.

Upvotes: 0

Related Questions