Why all your PCs should have PowerShell v2 remoting

There's no need to wait for Windows 7; you can simplify multiple-computer management today with Microsoft's newest version

PowerShell v2 is included with the forthcoming Windows 7, but you can take advantage of it in your business now. PowerShell is much more than a command-line interface replacement for CMD.exe (though you could limit yourself to just that usage). It's also a scripting language designed for admins to improve administrative control, as well as to add to efficiency and productivity.

[ Read J. Peter Bruzzese's blog entry "Unleashing the power of PowerShell." | Learn more about Windows 7 in his "Top 10 things I like about Windows 7." ]

Based on the Community Technology Preview version (so some features will improve or change in the final release), PowerShell v2 offers the following enhancements:

  • New and improved cmdlets. There are about 240 new cmdlets (the components of scripts) covering a wide range of functions such as remoting, type conversion, event viewing, script internalization, modules, transactions, debugging, eventing, background jobs, and WMI.
  • PowerShell remoting: Using WS-Management, you can now use cmdlets and scripting on remote systems (or multiple systems).
  • Transactions: Transacted operations include a rollback capability through the PowerShell Registry provider.
  • Modules: You can create modules that contain scripts and execute in self-contained, restricted runspaces.
  • Integrated Scripting Environment (ISE): This provides a GUI for PowerShell, with tabbed panes for up to eight Unicode-enabled consoles. (Get to it by choosing PowerShell in the Start menu's Accessories submenu.)
  • And more: Background jobs, script cmdlets, steppable pipelines, data language, script debugging, eventing, network file transfer, new operators, exception handling with Try-Catch-Finally, nestable Here-strings, block comments, and new APIs.

Of all these features, the one that really excites me is remoting, which is the ability to run commands (cmdlets) against remote computers. With it, you can run a script or command on another person's PC in PowerShell from your PC or server. It's like Remote Desktop at the command-line level.

A cool aspect of remoting is that it runs in a hidden window on the other person's PC, so they won't know you executed a command on their screen. (Well, tech-savvy users might notice your instance of PowerShell running in Task Manager.)

Another advantage to PowerShell remoting is the ability to fan out remote commands to run on multiple PCs. That lets you manage several PCs with one set of commands, saving you from repeating the work on each remote PC. There is nothing that makes an administrator's life easier than being able to reach out and touch other computers remotely.

The method for running a command against a remote computer is straightforward using the invoke-command cmdlet. For example, if you want to return the list of services running on a computer named Server1 by using the Get-Service cmdlet, run the following:

Invoke-Command -ComputerName Server1 -scriptblock {Get-Service}

To do that on multiple systems, type the following:

Invoke-Command -ComputerName Server1, Server2, Server3 -scriptblock {Get-Service}

It's clear that you'll use PowerShell v2 when Windows 7 ships, but you don't have to wait. You can download it today from Microsoft and install it in Windows XP, Vista, and Server 2003. You'll need the latest version (CTP3) of WinRM 2.0, which is Microsoft's implementation of the WS-Management, SOAP-based firewall-friendly protocol for remote management. Windows Vista comes with WinRM (though you may need to update to the CTP3 version), while XP and Server 2003 require you to download WinRM. You'll also need the .Net Framework 2.0 and, if you want to use PowerShell Integrated Scripting Environment, .Net Framework 3.5.1.

Copyright © 2009 IDG Communications, Inc.

How to choose a low-code development platform