Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Access denied" on Remote winrm [closed]

I created a Windows VM on Windows Azure with winrm over SSL set.

But, I can't connect it using a powershell script.

When I'm running the following:

​Enter-PSSession -ConnectionUri https://myniceapp.cloudapp.net:5986 
                -Credential "hostname/username"  
                -SessionOption (New-PSSessionOption -SkipCACheck -SkipCNCheck)

I'm getting a prompt asking for password and after I type it I manage to connect.

But, when I try to automate it, it always returns with "Access is denied"

$securePassword = ConvertTo-SecureString -AsPlainText -Force "password"
$cred = New-Object System.Management.Automation.PSCredential "hostname/username", $securePassword 
​Enter-PSSession -ConnectionUri https://myniceapp.cloudapp.net:5986 -Credential $mycreds -SessionOption (New-PSSessionOption -SkipCACheck -SkipCNCheck)

Any ideas?

Edit

The full error looks like this:

Enter-PSSession : Connecting to remote server myniceaspp.cloudapp.net 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 https://myniceaspp.cloudapp ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (https:// myniceaspp...udapp.net:5986/:Uri) [Enter-PSSession], PSRemotingTransportException
+ FullyQualifiedErrorId : CreateRemoteRunspaceFailed

like image 580
Guy Korland Avatar asked Mar 27 '14 06:03

Guy Korland


People also ask

Could not change the WinRM service type access is denied could not start the WinRM service access is denied?

Go to Manage local users of the computer. The local "Administrator" account is disabled and has no password set. So enable it and set a password. Then, as yourself, launch a cmd prompt, and runas /user:Administrator cmd.

How do I know if WinRM is working?

Type the following cmdlet and then hit Enter: "Restart-Service WinRM". It's time to test the connection, From the MID Server execute the following cmdlet into PowerShell and then hit Enter: "Test-WsMan <Target IP>" and This simple command tests whether the WinRM service is running on the remote Host.


1 Answers

Had similar problems recently. Would suggest you carefully check if the user you're connecting with has proper authorizations on the remote machine.

You can review permissions using the following command.

Set-PSSessionConfiguration -ShowSecurityDescriptorUI -Name Microsoft.PowerShell

Found this tip here:

http://blogs.technet.com/b/heyscriptingguy/archive/2010/11/17/configure-remote-security-settings-for-windows-powershell.aspx

It fixed it for me.

like image 139
Olivier Boudry Avatar answered Oct 11 '22 23:10

Olivier Boudry