Remote computing and PowerShell 2.0 part 1 – Getting started

It’s a pretty routine event for me to be remotely logged into more then one Windows server through Remote Desktop, or even occasionally sending a command from CMD to a remote server. PowerShell has not been left out of the game, when it comes to remote computing.  If you have a Windows 7, and a Windows 2008 machine, then everything you need has likely already been installed. In this blog I will discuss the steps needed to make and accept connections from PowerShell, and discuss running a single command on a remote computer. If not then you will need to download and install the Windows Management Framework Core package. You can find it here:

4 things must be in place before a computer will accept remote PowerShell connections.

  1. The WinRM service must be running.
  2. There must be a WinRM listener that accepts connections from one or more IP addresses.
  3. The Windows firewall must be configured to allow the WinRM connection.
  4. There must be an enabled and properly configured PowerShell session.

Now if the computer isn’t going to be accepting remote PowerShell connections, then you don’t need to worry about the above list.

Assuming that you will be accepting remote PowerShell connections, the First thing you will need to do is open PowerShell with administrative privileges.  This can be done by right clicking the PowerShell icon and selecting “Run as Administrator”.  Now execute the cmdlet Enable-PSRemoting . If you would like to read more about the cmdlet type Get-Help Enable-PSRemoting.

Now, the easiest way to connect to PowerShell on a remote computer is to use the Enter-PSSession cmdlet. As with all cmdlets if you need help type Get-Help CMDletName.

PS C:> Enter-PSSession servername

The above CMDlet is an example of what you would type to establish a connection to a remote server. Once you are connected to that server the PowerShell prompt changes to [servername]: PS C:>

Once you’re connected remotely, any commands you enter at the prompt are executed on the remote computer.  For example you can list the files and folders on the remote computer by typing [servername]: PS C:> Get-ChildItem C:

To end your session, type [servername] PS C:> Exit-PSSession

Next time I’ll continue this by showing you how to run a Scriptblock on a remote computer!

Leave a Reply