PowerShell Cookbook V2 Now Available

Update 1/22/2013: The much expanded third edition is now available.

On Friday, we wrapped up the final details of the PowerShell Cookbook, V2. O’Reilly has already made the electronic edition available, which is a great resource for searching, copying, pasting, and working with the content in its native form. If you or your company subscribes to Safari, it should be available shortly.

If you’re a fan of the printed version, it’s off to the printers now, and has a scheduled “in-stock” date of 8/24: the date when it’ll be in boxes in the shipping / receiving area of book stores. It takes about a week for books to migrate onto shelves, so the official “when can I get it” date is 8/31.

Aurora Monitoring with PowerShell

Over the past few days, Astronomy resources have been making a big splash about a couple of coronal mass ejections (CME) primed to cause widespread visibility of the Aurora Borealis. Last night was when the first one hit, and its effects extended deeply into southern Canada and parts of the northern US.

There may be another round tonight, so maybe this post can help you catch your first Aurora :)

NOAA has a couple of good resources, and one I was keeping special track of shows where the effects are the greatest:

Hang Drum for Propellerheads Reason

One instrument that’s got great allure is the PanArt Hang – a metallic drum-like form with great complexity and resonance:

They are difficult to obtain, and expensive should you want to try.

Looking online, I found some WAV samples graciously provided by Andreas Bick at http://www.andreas-bick.de/hang-samples/. He also included the sampler settings to convert this to a virtual instrument for Apple Logic Pro’s ESX-24 sampler.

Which Files Support Authenticode Signatures?

An interesting question came up today about the Set-AuthenticodeSignature cmdlet. It actually supports more than just .ps1 files, but what files exactly?

It turns out that this isn’t actually possible to know programmatically. Your best bet is to hard-code a list of things you know or can scrounge from the internet :) The ones I am aware of off-hand are:

.CAB, PE formats (.EXE, .DLL, etc) , .CAT, .MSI, .JAR,.OCX, .PS1, .PSM1, .PSD1, .PS1XML, .PSC1

Open PowerShell Cookbook Beta Available Online

With the first draft of the Windows PowerShell Cookbook complete, we’re running an open beta through a cutting-edge platform called the Open Feedback Publishing System: http://powershell.labs.oreilly.com. In this system, we put the entire book online and let you read to your heart’s content.

Not only is the book available online, but you can also influence its future. The Open Feedback Publishing System lets you attach comments to any paragraph as though you would comment on a blog.

HTML Agility Pack Rocks Your Screen Scraping World

I had to do some deep data extraction from a web page today, and naturally leaned on PowerShell for some assistance. PowerShell is a great language for text munging, and web content is no different. There are tons of examples online, but here’s an example from earlier in this blog: http://www.leeholmes.com/blog/PowerShellTheOracleInstantAnswersFromYourPrompt.aspx.

As I looked at the underlying HTML of this page, though, my heart sank. I cared about four pieces of data, and they were arranged without much structure on the web page. The information I cared about was in a couple of different tables, a couple of different table rows, and sometimes in different columns. You can parse your way around this, but it’s simply error-prone and annoying.

Responding to USB Devices in PowerShell

I recently got a cool USB MIDI keyboard (M-Audio Axiom 49) and software (Propellerhead Reason) combo that lets me play keyboard with all kinds of cool sounds effects and general fun. Despite how cool the system is, it’s not quite as spontaneous as a plain ol’ electronic keyboard. Just to piddle around for a bit, you have to turn on the keyboard, launch Reason, create a new song, add a virtual instrument, and then start playing.

PowerShell Hotkey to Pause Pandora

I’ve got a neat application that I use to map keystrokes to background PowerShell functions / script blocks. I recently started using Pandora more often, and the killer problem is when somebody drops by the office to ask a quick question. You dig around all of your open Explorer windows until you find the one for Pandora, then find the Pause button.

Here’s a function that does all of that for you, and maps it to Control+Alt+P:

Looking for Reviewers for PowerShell Cookbook v2

We’re getting close to “content complete” of the Windows PowerShell Cookbook, 2nd edition. The next step is technical review, where we look for both high-level and low-level feedback on the content and structure.

Also, this is a book focused on administrators. While PowerShell uber-hackers are always appreciated, inexperience with PowerShell is extremely valuable, as well.

If you’re interested in being a Technical Reviewer of the book, participate in its Open Beta!

Delayed Screen Captures in PowerShell

Here’s one that’s short and sweet. A lot of programs exist for the sole purpose of taking a screen shot after a certain amount of time. For example, delay for 10 seconds before taking a screen shot so that you have the time to open some menus.

This is incredibly simple with PowerShell:

Add-Type -Assembly System.Windows.Forms
Sleep 10

## Capture the entire screen
[System.Windows.Forms.Sendkeys]::SendWait("{PrtSc}")

## Capture the current window
[System.Windows.Forms.Sendkeys]::SendWait("%{PrtSc}")