1

I have set up a domain controller server on Azure with Windows Server 2016. Now I want to connect to this server using PSSession.

WinRM is enabled, all firewall rules are ok, inbound rules on Azure network security group too, but I can't connect to the server.

Enter-PSSession : Connecting to remote server a.b.c.d failed with the following error message : WinRM cannot complete the operation. Verify that the specified computer name is valid, that the computer is accessible over the network, and that a firewall exception for the WinRM service is enabled and allows access from this computer. By default, the WinRM firewall exception for public profiles limits access to remote computers within the same local subnet.

I can connect to this server using RDP only, but no success with WinRM.

Any thoughts?

1
  • in a admin powershell what does "winrm get winrm/config" look correct? AllowRemoteShellAccess = True, correct port HTTP/HTTPS that are in your firewall rules, would check that no GPO is forcing any different powershell settings
    – SpiderIce
    Oct 19 '17 at 18:04
1

I can connect to this server using RDP only, but no success with WinRM.

To Winrm Azure VM, we should add port 5985 to Azure VM NSG inbound rules. Also we should add port 5985 to Windows server 2016 windows firewall inbound rules.

We can follow this step to enable winrm for this VM:

1.Add port 5985 to Azure VM NSG inbound rules.
2.Add port 5985 to Azure VM windows firewall inbound rules.
3.Enable Winrm settings in Azure VM, use this command winrm quickconfig
4.Add trust host to your local PC, use this command

Set-Item wsman:\localhost\Client\TrustedHosts -value *

5.Then use this script to Winrm your VM:

$username = 'jason'
$pass = ConvertTo-SecureString -string 'Password' -AsPlainText -Force
$cred = New-Object -typename System.Management.Automation.PSCredential -argumentlist $username, $pass
$s = New-PSSession -ConnectionUri 'http://13.xx.xx.89:5985' -Credential $cred -SessionOption (New-PSSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck)
Invoke-Command -Session $s -ScriptBlock {get-process}

More information please refer to this link.

2
  • As I said: "WinRM is enabled, all firewall rules are ok, inbound rules on Azure network security group too, but I can't connect to the server." Oct 20 '17 at 13:14
  • @zairhenrique can you telnet your port 5985?
    – Jason Ye
    Oct 20 '17 at 13:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.