PowerShell: Windows Administration Evolved

Yesterday Microsoft released their new command shell, Windows PowerShell (via Aaron Tiensivu). This next-generation shell offers an administrative environment that strives to replace a jumble of administrative commands with a consistent, extensible interface.

Consider traditional Windows system administration tools — it is possible to automate administrative tasks with powerful commands like sc, netsh, and cacls. But each of these commands presents an esoteric interface with inconsistent command line options, and built-in documentation is sparse at best. Likewise, scripting with VBScript/JScript has good potential, but interaction with executables requires excessive housekeeping, and COM object interfaces are also inconsistent.

Unlike Windows’ monolithic commands, *nix has long offered a wide range of simple commands whose text input/output is easily strung together to perform useful tasks. Certain command line options are consistent enough (e.g. “-v”), and the man/info help system facilitates on-line documentation.

Enter PowerShell, which evolves *nix pipe concept to process .NET objects rather than simple text. The basic element of PowerShell’s object-oriented pipeline is the cmdlet (pronounced “command-let”). These simple commands follow a verb-noun naming convention that indicates their purpose. For example, Get-Service outputs the services on the local machine as service objects; Set-Date sets the clock. Functionality is so granular that output formatting is isolated to format- cmdlets, and output is the responsibility of output- cmdlets. For example:

PS C:\> Get-Process notepad | Stop-Process

Get-Process notepad passes a list of .NET process objects named “notepad” (specifically, System.Diagnostics.Process), and passes them to Stop-Process, which kills them. It would be just as easy to access any of the other Process properties or methods.

Extensive built-in help is available. The command Get-Help details it’s own options, and is a good place to start. Combined with the integrated scripting language, PowerShell + .NET is a clean alternative to VBScript/JScript + COM.

PowerShell 1.0 is available for download. Microsoft’s What Can I Do with Windows PowerShell? offers basic examples to get started. I also recommend the documentation pack, which includes a more extensive 32-page Getting Started Guide as well as a 116-page primer. full documentation is available on MSDN.

Be Sociable, Share!

Tags: , ,

2 Responses to “PowerShell: Windows Administration Evolved”

  1. JonnyRo says:

    Are there any examples of regular expression use in powershell?

    Can it work through text files, parse xml files, etc?

  2. herbal breast enhancement pills

    PowerShell: Windows Administration Evolved « Nathan’s Blog

Leave a Reply

Are you human? Answer this: *