"Access denied" on remote winrm

I created a Windows virtual machine on Windows Azure using winrm over SSL.

But I can not connect it using powershell script.

When I run the following:

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

I get a request with a password, and after entering it, I can connect.

But when I try to automate it, it always comes back with "Access 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: The connection to the remote myniceaspp.cloudapp.net server failed with the following error message: access denied. For more information, see the help topic about_Remote_Troubleshooting.

: 1 char: 1
+ Enter-PSSession -ConnectionUri https://myniceaspp.cloudapp...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo: InvalidArgument: (https://myniceaspp... udapp.net:5986/:Uri) [Enter-PSSession], PSRemotingTransportException
+ FullyQualifiedErrorId: CreateRemoteRunspaceFailed

+4
1

. , , , .

.

Set-PSSessionConfiguration -ShowSecurityDescriptorUI -Name Microsoft.PowerShell

:

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

.

+8

Source: https://habr.com/ru/post/1533667/


All Articles