“Access denied” on Remote winrm [closed]

陌路散爱 提交于 2019-12-10 03:22:37

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/22680211/access-denied-on-remote-winrm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!