Prof. Powershell
PowerShell 2.0 Remoting
WMI is no longer necessary for managing remote computers with PowerShell. Here's how to extend your management grasp.
- By Jeffery Hicks
- 06/30/2009
In PowerShell 1.0, working with remote computers meant using Windows Management Instrumentation (WMI), fussing with firewall ports and troubleshooting RPC connectivity. PowerShell 2.0 will allow you to reach out and manage remote computers in a variety of ways from the relative comfort of your desk. But of course there are requirements.
First off, you'll need PowerShell 2.0 installed not only on your desktop, but also any remote computer you want to manage. Initially, you'll be limited to Windows 7 and Window Server 2008 R2, but eventually everything after Windows XP should be supported. You'll also need to install Windows Remote Management (WinRM) 2.0. These bits should ship with Windows 7 and Server 2008 R2. Most likely they will be integrated in later PowerShell 2 installation packages for other operating systems. While technically not required, you'll find WinRM easier to set up and use in a domain environment. As you might expect Vista and newer systems will require administrative privileges in an elevated session.
Configuring a computer for remoting is as simple as opening an elevated PowerShell prompt and running a simple command:
PS C:\> enable-psremoting
That's it! The cmdlet handles all the WinRM service configuration, including firewall exceptions. Look at the cmdlet's help to see what actions will be performed on your system. If you later decide to stop using remoting, you can disable WinRM like this:
PS C:\> disable-psremoting
To verify that the remote protocols are working properly, use the Test-WSMan cmdlet:
PS C:\> test-wsman
You'll also be able to use Group Policy on a Windows Server 2008 domain controller to configure WinRM. Once remoting has been enabled, you;ll be able to run sessions interactively on remote computers. You'll be able to run commands as background jobs on remote computers and retrieve the results on your computer. We'll cover these techniques and more in future columns and you'll wonder how you ever managed without PowerShell before.
In the mean time, you can learn more about WinRM and other Windows infrastructure technologies at http://blogs.msdn.com/wmi/.
About the Author
Jeffery Hicks is an IT veteran with over 25 years of experience, much of it spent as an IT infrastructure consultant specializing in Microsoft server technologies with an emphasis in automation and efficiency. He is a multi-year recipient of the Microsoft MVP Award in Windows PowerShell. He works today as an independent author, trainer and consultant. Jeff has written for numerous online sites and print publications, is a contributing editor at Petri.com, and a frequent speaker at technology conferences and user groups.