Windows PowerShell Holiday Gift Guide

Books

As Groucho Marx once said, “Outside of a dog, a book is man’s best friend. Inside of a dog, it’s too dark to read.” What does that mean? Why, that simply means that … well, OK: to tell you the truth, we don’t have any idea what that means. What we do know, however, is that, inside a dog or outside a dog, books always make for thoughtful and much-appreciated gifts. And if you have a PowerShell user or two on your gift list, you’ve got plenty of good books to choose from.

On This Page
Windows PowerShell CookbookWindows PowerShell Cookbook
Windows PowerShell in ActionWindows PowerShell in Action
Windows PowerShell Step-by-StepWindows PowerShell Step-by-Step
Windows PowerShellWindows PowerShell
Windows PowerShell: TFMWindows PowerShell: TFM
*
**
**

Windows PowerShell Cookbook

Windows PowerShell Cookbook

For example, hot off the presses is the Windows PowerShell Cookbook (O’Reilly; $49.99). Written by Lee Holmes, a developer on the PowerShell team, the Cookbook is a practical guide to using Windows PowerShell; inside you’ll find hundreds of “recipes” for using PowerShell to carry out routine system administration tasks. As Lee noted in a Script Center interview, “The idea of a cookbook is that we just tell people how to do things. People don’t necessarily want to know all the ins and outs of a language; instead, they just want to back up an event log. Well, we have a recipe for that.”

Speaking of event logs, here’s a script from Lee’s book that shows you how to write a record to an event log named ScriptEvents:

$log = Get-EventLog – List | Where-Object {$_.Log –eq "ScriptEvents"}
$log.Source = "PowerShellCookbook"
$log.WriteEntry("This is a message from my script.")

And here’s a script that lets you grab information from the System event log on a remote computer named LEE-DESK:

$log = New-Object Diagnostics.EventLog "System", "LEE-DESK"
$log.Entries | Group-Object Sourcce

Very nice.

Top of pageTop of page

Windows PowerShell in Action

Windows PowerShell in Action

Of course, some people do want to know the ins and outs of a language; for those people, there’s Windows PowerShell in Action (Manning Publications; $49.99) written by Bruce Payette, another developer on the PowerShell team. Will PowerShell in Action really give you the ins and outs of the PowerShell language? Let’s put it this way: Bruce co-designed, and was in charge of implementing, that language. So, yes, there’s a pretty good chance he knows what he’s talking about.

Here’s a sample script from Windows PowerShell in Action. This script downloads the RSS feed from the PowerShell team blog, and then displays the title and a link for each blog entry:

([xml](new-object net.webclient).DownloadString `
("http://blogs.msdn.com/powershell/rss.aspx")).rss.channel.item | 
format-table title,link

Note. By the way, you can read a sample chapter from Bruce’s book right here in the Script Center.

Top of pageTop of page

Windows PowerShell Step-by-Step

Windows PowerShell Step-by-Step

If that certain special someone on your gift list is a newcomer to Windows PowerShell you might want to take a peek at Windows PowerShell Step-by-Step (Microsoft Press; $39.99) written by Microsoft’s Ed Wilson. PowerShell Step-by-Step “delivers self-paced labs, timesaving tips, and hands-on sample scripts for automating Windows administration—one step at a time.” What more could you ask for?

Well, OK, one thing you might ask for is a PowerShell script that can create an Active Directory user account. Here’s just such a script, taken from Ed’s book:

$strClass = "User"
$StrName = "CN=MyNewUser"
$objADSI = [ADSI]"LDAP://ou=MyTestOU,dc=nwtraders,dc=com"
$objUser=$objADSI.create($strClass, $StrName)
$objUser.Put("sAMAccountName", "MyNewUser")
$objUser.setInfo()
Top of pageTop of page

Windows PowerShell

Windows PowerShell

But what if that certain special someone has insisted that you not spend any money on them this holiday season? (Yes, it is hard to believe that anyone like that exists, but …) In that case, don’t spend any money on them; instead, download Frank Koch’s Windows PowerShell training manual (free download; Windows Live ID required). Obviously this 40-page manual isn’t as extensive as any of the full-scale PowerShell books. However, it does provide a nice overview and a friendly, easy-to-understand introduction to Windows PowerShell. And you can’t beat the price, right?

Here’s a sample script from Frank’s training manual:

dir $env:windir\*.log | 
select-string -list error | 
format-table path,linenumber –autosize

What does this script do? Something pretty darn handy: it creates a list of all log files in the “Windir” folder then searches each file for the word Error. If the script encounters the word Error it echoes back the log file name and the line where the target word was found.

This just in. Frank has recently upgraded his download to include a second free book: Administrative Tasks Using Windows PowerShell.

Top of pageTop of page

Windows PowerShell: TFM

Windows PowerShell: TFM

Last, but very far from least, we have Windows PowerShell: TFM by Don Jones and Jeffrey Hicks (Sapien Press; $34.99 for the eBook second edition, with the print version to be available shortly). People who bought the first edition of PowerShell: TFM probably thought it contained everything you could possibly want to know about Windows PowerShell. Those people were mistaken: the new edition contains approximately 25% more material than the first edition does. If you have a question about PowerShell there’s a pretty good chance you’ll find the answer in here.

Oh, and guess what? Don and Jeffrey already are hard at work on a third edition of the book, one that covers the new capabilities included in the CTP release of PowerShell 2.0. Visit this Web page for more information.

Here’s a sample script from Windows PowerShell: TFM. This script prompts you to enter a WMI class name (for classes in the root\cimv2 namespace). The script then binds to that class and retrieves and displays all the properties of the class.

Yeah, we thought it was pretty cool, too. Here’s the code:

$class=Read-Host "Enter a Win32 Class that you are interested in"
$var=get-WMIObject -class $class -namespace "root\Cimv2"
$properties=$var | get-member -membertype Property
Write-Host "Properties for "$Class.ToUpper()
foreach ($property in $properties) {$property.name}

Note. So what does the TFM in Windows PowerShell: TFM stand for? You’ll have to ask Don and Jeffrey about that ….

Next: Workflow Studio


Top of pageTop of page