Setting up remote power shell from different domains

So I have had the pleasure (sarcasm, massive amounts of sarcasm) in dealing with remote power shell in the last couple of days  So I figured I would write a quick guide on how you can connect to another machine, outside of your domain, with remote Power shell.  This is useful if you want to run Exchange cmdlets from your local machine, run tests on your local power shell instance while connecting to a test lab, or countless other ways.  First lets talk about remote power shell, and what it is.

Remote power shell is a tool that allows you to remotely managed services using WS-Management protocol and the Windows Remote Management (WinRM) service.    The WS-Management protocol is a public standard for remotely exchanging management data with any computer device that implements the protocol. The WinRM service processes WSMan requests received over the network. It uses HTTP.sys to listen on the network.

In my test scenario, I am trying to connect to my test lab (testlab.com) with remote powershell, from my work machine (workdomain.com)  The first problem that I am going to come across is that my machines are in different domains, and we are not going to be able to create a trust between them.  I found a great KB that walked me through the actual technical piece.

I have listed those steps here

 

1. Start Windows PowerShell as an administrator by right-clicking the Windows PowerShell shortcut and selecting Run As Administrator.

2. The WinRM service is confi gured for manual startup by default. You must change the startup type to Automatic and start the service on each computer you want to work with. At the PowerShell prompt, you can verify that the WinRM service is running using the following command:
get-service winrm
The value of the Status property in the output should be “Running”.

3. To configure Windows PowerShell for remoting, type the following command:
Enable-PSRemoting –force

In many cases, you will be able to work with remote computers in other domains. However, if the remote computer is not in a trusted domain, the remote computer might not be able to authenticate your credentials. To enable authentication, you need to add the remote computer to the list of trusted hosts for the local computer in WinRM. To do so, type:
winrm s winrm/config/client ‘@{TrustedHosts=”RemoteComputer”}’
Here, RemoteComputer should be the name of the remote computer, such as:
winrm s winrm/config/client ‘@{TrustedHosts=”CorpServer56″}’

 

A few problems that I came across.

  1. Even after adding the machine to the trusted hosts, you still get the same errors inside power shell that says unable to connect.  Make sure you are running power shell as an administrator
  2. Make sure you can ping and telnet the ports you are using
  3. Make sure that if your going over HTTP that the server your connecting to has the turned on, for example,if your going to connect to an Exchange server for remote power shell, make sure that IIS directory allows connections on port 80