Now Available:

Featured Resource:

line

Newsletter

Email Address:


line

Ask the Expert

Have a question for our resident expert? Email your questions to Greg.

« Server 2008 RC1 Released. So, What's New? | Main | Reader Comments about "IE vs. FireFox: Who's the Safest Browser of them All?" »

Don Jones’ Favorite PowerShell Cmdlets, Part 9 of 10: ConvertTo-HTML

I think we can all agree that bosses love reports, right? Check this out:

gwmi win32_service -comp Server2 | where { $_.StartMode -eq “Auto” -and $_.State -ne “Running” }

A list of all services on Server2 which should be running, but which aren’t. However, not a terribly great report for management - after all, they’re not likely to have PowerShell. Why not do this instead?

gwmi win32_service -comp Server2 | where { $_.StartMode -eq “Auto” -and $_.State -ne “Running” } | select name,state | convertto-html | out-file \\intranet\wwwroot\reports\notrunningserver2.html

An instant HTML-formatted report, copied right to my intranet Web server. But wait - there’s more.

Click past the fold for more…

Help ConvertTo-HTML

That’s right, read the friendly manual (RTFM - that’s where the “TFM” in my book’s title, Windows PowerShell: TFM, 2nd Edition, comes from). Notice all the cool options for ConvertTo-HTML? For example, you can insert CSS style sheet links into the head section of the output HTML - very cool, as it makes prettier reports for the boss. You could also specify a title for the report, or insert some explanatory text into the body section, just before your actual report info. Play around with it - ConvertTo-HTML is a fun, useful gadget to play with. We spend a lot of time in my classes seeing what it can do, in fact (want to come? www.ScriptingTraining.com/ilt/schedule.asp - I’ll see you there).

Don Jones is the Lead Scripting Guru for SAPIEN Technologies and a Windows PowerShell MVP. He’s the co-author of Windows PowerShell: TFM, 2nd Edition and is the Windows PowerShell columnist for TechNet Magazine. Don is also the Director for the new centralized, independent PowerShell online community: www.PowerShellCommunity.org.

Get your hands on the full Don Jones Favorite Cmdlets Series at this address:
http://www.realtime-windowsserver.com/type/mt-search.cgi?tag=don%20jones%20favorite%20cmdlets&blog_id=1

TrackBack

TrackBack URL for this entry:
http://www.realtime-windowsserver.com/type/mt-tb.cgi/508

Post a comment

(All comments are approved by site leader before appearing here. Thanks for commenting!)

line

Greg Shields' Bio:

Greg Shields, is an independent author, instructor, and IT consultant based in Denver, Colorado, and a co-founder of Concentrated Technology. With nearly 15 years of experience in information technology, Greg has developed extensive experience in systems administration, engineering, and architecture specializing in Microsoft systems management, remote application, and virtualization technologies. Greg is a Contributing Editor for Redmond Magazine, MCPmag.com, and Virtualization Review Magazine and is the author of five books, including Windows Server 2008:  What’s New / What’s Changed. Greg is also a highly sought-after instructor and speaker, speaking regularly at conferences like TechMentor Events, and producing computer-based training curriculum for CBT Nuggets.  Greg is a recipient of Microsoft "Most Valuable Professional" award with a specialization in Windows Terminal Services.