Thanks to all the cool folks who attended today's webcast: Exchange Server 2007 Management Shell and Scripting (Level 300). As promised, here are the scripts I used. I first saw Out-IE used by the awesome Jim Truher. I wrote it recently when one of my colleagues asked if we there was a way to pop-up html pages without calling IE manually. Here it is:
$ie = new-object -com InternetExplorer.Application
$ie.navigate("about:blank")
while ($ie.busy) { sleep 1 }
$ie.visible = $true $ie.document.write("$input")
# if above line doesn't work on your system, uncomment line below
# $ie.document.IHTMLDocument2_write("$input")
$ie
Put the lines above in a msh/ps1 file and run it (example below)! As for Out-HTML, there actually is a cmdlet built into PowerShell/Monad called "ConvertTo-Html". I wrote Out-HTML to kind of prove the point that you can have generic scripts for creating reports.
It additionally has two features that CovertTo-HTML does not have: 1) it shows you what cmd you ran to create the report (super handy if you create a report and then forget what you did to create it :) and 2) it handles different object outputs a little differently so that it makes reports easier to read. Its a little prettier too. Here it is.
To run the script, rename it out-html.msh (Exchange/RC0) or out-html.ps1 (PowerShell RC1) and place it somewhere in your PATH (or alternatively give the full path to the script when running it). Example:
get-childitem | select Name,Length | out-html > foo.html get-childitem | select Name,Length | out-html | out-ie
Please feel free to show off your customizations to the scripts above or just reuse them as is. I'd love to see what kind of cool Exchange reporting tricks people will come up with. Oh, and if you still have unanswered questions after the webcast, feel free to leave a comment or trackback.