PowerShell Transcript trick for HTML

As a teacher I use Transcripts constantly to record my demonstrations.  Students can download them at their leisure and they don’t have to write things down in class.  I know most of you presenters do the same thing.  I prefer to let students use the transcripts during the day when they are working on labs, so I want them to be easily viewable.

There are a couple of problems with transcripts in my world.  First, every time I close the shell, I have to remember to start them again.  I know, just put it in my profile but wait there is more….. Two, I want them in html, not just text.

You might be saying, well your world is kinda stupid, but hear me out on the html thing.  See, On my presentation computer, I want to install IIS and use the default web site for the transcript.  Students could then view the building transcript anytime they want just by opening their browser and navigating to the URL.  See, could be really cool.

The problem is that the Transcript cmdlet’s are like Out-File, they send everything to a file as text.  Darn, no objects.  That means I can’t use the pipeline to ConvertTo-HTML.  You can see below that the transcript looks fine in notepad, but sucks in a browser.

Screen Shot 2011-11-26 at 3.49.39 PMScreen Shot 2011-11-26 at 3.50.13 PM
Now, I could write some fancy function, but instead here’s my simple solution any admin can do.  See what you think.

1.  Here’s the really cool part of my solution. After installing IIS with a quick Add-WindowsFeature Web-Server, use notepad to create the default.htm. At the top, put an open PRE tag. <PRE> Don’t worry about closing the tag. Everyone say “Thank god for invalid rendering of HTML!” and save the default.htm. (p.s.  Thanks Mike Pfeiffer)

Screen Shot 2011-11-26 at 3.57.10 PM

2.    I put Start-Transcript in my profile and have it append the default.htm in c:\inetpub\wwwroot. 

Start-Transcript c:\inetpub\wwwroot\default.htm -Append

3.  Your done.  That’s right, your done.  Every time you open PowerShell, it appends the transaction to the default.htm.  Simply give the students (or whoever) you server name.  Pretty cool huh?

Screen Shot 2011-11-26 at 3.59.51 PM

Knowledge is PowerShell,
Jason


One thought on “PowerShell Transcript trick for HTML

Comments are closed.