Search This Blog

Monday, July 19, 2010

Debugging Exchange PowerShell scripts in PowerShell 2

I'm fixing a number of PowerShell v1.0 scripts to get them to work underPowerShell v2.0 and found the basic script editor/debugger that comes with PSv2, "ISE."

It's a lightweight version of PowerGUI (which I never spent enough time with) that has pretty decent debugger features.

All of the scripts I'm upgrading make calls to the Exchange Admin extensions and I got stymied getting the debugger to load the Exchange 2007 Admin extensions. I kept looking for an "options" feature or some other way to set up a reference to the extensions through menu item choices on ISE but couldn't find anything appropriate.

A quick question to our Exchange admin showed how to get around it: one of the windows in the debugger is a PowerShell script prompt. Just put this in that window:

Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin

Very simple. This'll load the extensions and you can then get back to debugging.

No comments: