BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Free PowerShell Book

Free PowerShell Book

Frank Koch of Microsoft Switzerland has released a free mini-book on Windows PowerShell.

Windows PowerShell is a replacement for the DOS-based command prompt currently distributed with Windows. Inspired by the powerful shells found in Linux, PowerShell gives administrators full access to COM and .NET libraries from the command prompt.

One of the key topics covered by this book is piping. Unlike UNIX based shells, PowerShell doesn't pipe just text. Instead, it is based on the ability to pipe objects from one command to the next.

For example, consider this command.

get-wmiobject -class win32_computersystem | get-member | sort name

The first part gets the WMI object Win32.ComputerSystem.
In order to get a list of methods on the object, it is piped to the get-member command.
Finally, the list is piped to the sort command.

The concept of file systems and objects have been merged in PowerShell. This allows you to register an object model and explore it like a file system. Built-in "drives" include the Windows Registry, certificate stores, environmental variables, and aliases. There is even a "Variable" drive for working with shell variables. Just as in an actual drive, features such as Tab Completion work in these pseudo-drives.

Other interesting tricks found in this book include PowerShells support for numeric constants. Wherever numbers are allowed, one can write "512KB" and the shell will automatically convert into bytes. The suffix MB and GB are also supported.

You can download the book and sample code from the Scattered Notes blog. 


Rate this Article

Adoption
Style

BT