Enter-PSSession Error for my own vm

Hi,

I am new to powershell and new to the forum.

I am trying to remote into one vm from another vm and I am getting the following error:

[i]Enter-PSSession : Connecting to remote server ritwikdevbox4 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. For more information, see the about_Remote_Troubleshooting Help topic.
At line:1 char:1

  • Enter-PSSession -ComputerName ritwikdevbox4
  •   + CategoryInfo          : InvalidArgument: [ritwikdevbox4:String] [Enter-PSSession], PSRemotingTransportException
      + FullyQualifiedErrorId : CreateRemoteRunspaceFailed[/i]
    
    
    

Here are the steps I have taken prior to this:

  1. Setup a new vm on Azure with a Windows Server 2012 R2 image called ritwikdevbox2
  2. Setup a second vm on Azure with a Windows Server 2012 R2 image called ritwikdevbox4. It is in the same domain as ritwikdevbox2

Here are the nslookup output on ritwikdevbox2 prompt:

PS [ritwikdevbox2] > nslookup ritwikdevbox2
[i]Server: UnKnown
Address: 168.63.129.16

Name: ritwikdevbox2.ritwikdevbox2.d2.internal.cloudapp.net
Address: 1xx.16.0.4[/i]

PS [ritwikdevbox2] > nslookup ritwikdevbox4
[i]Server: UnKnown
Address: 168.63.129.16

Non-authoritative answer:
Name: ritwikdevbox4.ritwikdevbox2.d2.internal.cloudapp.net
Address: 1xx.16.0.6[/i]

  1. Ran Enter-PSSession from ritwikdevbox2

PS [ritwikdevbox2] > Enter-PSSession -ComputerName ritwikdevbox4

Error received
[i]Enter-PSSession : Connecting to remote server ritwikdevbox4 failed with the following error message : The WinRM client cannot process the request. If the authentication scheme is different from Kerberos, or if the client computer is not joined to a domain, then HTTPS transport must be used or the destination machine must be added to the TrustedHosts configuration setting. Use winrm.cmd to configure TrustedHosts. Note that computers in the TrustedHosts list might not be authenticated. You can get more information about that by running the following command: winrm help config. For
more information, see the about_Remote_Troubleshooting Help topic.
At line:1 char:1

  • Enter-PSSession -ComputerName ritwikdevbox4
  •   + CategoryInfo          : InvalidArgument: [ritwikdevbox4:String] [Enter-PSSession], PSRemotingTransportException
      + FullyQualifiedErrorId : CreateRemoteRunspaceFailed[/i]
    
    

Issue fixed by:
PS [ritwikdevbox2] > Set-Item wsman:localhost\client\trustedhosts -Value ritwikdevbox4

Again trying Enter-PSSession
PS C:\Users\ritwikadmin> Enter-PSSession -ComputerName ritwikdevbox4

Here is the error I receive:

[i]Enter-PSSession : Connecting to remote server ritwikdevbox4 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. For more information, see the about_Remote_Troubleshooting Help topic.
At line:1 char:1

  • Enter-PSSession -ComputerName ritwikdevbox4
  •   + CategoryInfo          : InvalidArgument: [ritwikdevbox4:String] [Enter-PSSession], PSRemotingTransportException
      + FullyQualifiedErrorId : CreateRemoteRunspaceFailed
    

[/i]

I realize that I probably am making a very silly mistake. I probably need to open up a port or something of that sort. But I have spent more than a few hours trying to move beyond this and I cannot. Please help.

Please help. Please do not assume anything. I am new to windows technology. So I might be missing the smallest bit of things.

Thanks in advance.

Ritwik

Look how it’s set in domain, maybe you fill get idea how to setup in your environment.

Can you run

Get-NetConnectionProfile
on ritwikdevbox4.

If it responds with public, set it to private or domain if you can, and try connecting to it again.