WinRM on Azure RM VM

1

I'm trying to connect to an AzureRM VM. I've read through so many tutorials on WinRM but I still cannot get this to work:

    Enter-PSSession -ComputerName "$($HOST).cloudapp.net" -Credential $username

When I run this, I get the following error:

The user name or password is incorrect. For more information, see the about_Remote_Troubleshooting Help topic

When I add the -UseSSL param I get this error:

The WinRM client cannot process the request because the server name cannot be resolved. For more information, see the about_Remote_Troubleshooting Help topic.

The credentials I'm entering are correct. So I also tried "localhost\$username" and I get a different error:

The following error with errorcode 0x80090311 occurred while using Kerberos authentication:

So I tried to use -Authentication basic and I get:

The WinRM client cannot process the request. Unencrypted traffic is currently disabled in the client configuration

But I have already checked and unencrypted traffic is enabled.

Has anyone come across this issue before? Any suggestions as to what to try next?

    credentials = Get-Credential -UserName $username -Message "Enter Azure account credentials"
    $continue=$false
    Do{
$session = New-PSSession -ComputerName "$($VMName).cloudapp.net" -Credential $credentials 
if ($session -ne $null)
{
  $continue=$true
}
Write-Output "Unable to create a PowerShell session . . . sleeping and trying again in 30 seconds."
Start-Sleep -Seconds 30
      }
   Until(
$continue=$true)

EDIT Adding what the settings are now on the Server:

   WSManConfig: Microsoft.WSMan.Management\WSMan::localhost\Client

Type            Name                           SourceOfValue   Value
----            ----                           -------------   -----
System.String   NetworkDelayms                                 5000
System.String   URLPrefix                                      wsman
System.String   AllowUnencrypted                               true
Container       Auth
Container       DefaultPorts
System.String   TrustedHosts

And the client:

   WSManConfig: Microsoft.WSMan.Management\WSMan::localhost\Client

 Type            Name                           SourceOfValue   Value
 ----            ----                           -------------   -----
 System.String   NetworkDelayms                                 5000
 System.String   URLPrefix                                      wsman
 System.String   AllowUnencrypted                               true
 Container       Auth
 Container       DefaultPorts
 System.String   TrustedHosts                                   @{Value = "XX.XX.XX.XX"}
powershell
azure
winrm
asked on Stack Overflow Jan 10, 2017 by Xanderu • edited Jan 12, 2017 by Xanderu

2 Answers

0

Maybe you could try to use the following cmdlets. I test in my lab. It works for me.

$SecureString = Read-Host -AsSecureString 'Enter your password ' | ConvertFrom-SecureString | ConvertTo-SecureString $MySecureCreds = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "yourusername",$SecureString Enter-PSSession -ComputerName "yourcomputername" -Credential $MySecureCreds

I find a similar question with you, maybe you could check.

Update:

On WinRM server, please try to execute the following cmdlet.

winrm quickconfig

You will get the following messages.

WinRM service is already running on this machine. WinRM is already set up for remote management on this computer.

On client PC, please try to execute the following cmdlet by using Administrator account.

winrm set winrm/config/client '@{TrustedHosts = "server IP"}'

answered on Stack Overflow Jan 11, 2017 by Shui shengbao • edited May 23, 2017 by Community
0

Below parameter helps to connect the Azure VM through WINRM

    $hostName="DomainName" 
$winrmPort = "5986"
# Get the credentials of the machine
$cred = Get-Credential
# Connect to the machine
$soptions = New-PSSessionOption -SkipCACheck
Enter-PSSession -ComputerName $hostName -Port $winrmPort -Credential $cred -SessionOption $soptions -UseSSL
answered on Stack Overflow Jun 7, 2017 by Vinoth Ramamoorthy

User contributions licensed under CC BY-SA 3.0