Dude, Where's My Manual?

PowerShell Team

Windows PowerShell comes with a lot of help files and documents, but, somehow, my favorite and most-frequently-used help is the help that  I get by typing “Get-Help” in the console.


And I have always wondered why this help is not readily available as a  single document, ready to be viewed, searched, and printed. Well, now it is, with this simple Get-Manual script.


This script merges all of the about_* help content with cmdlet help, and puts it into one pretty formatted Microsoft Word document (.doc). Once you have this document, you can search it for specific content. Or, you can print it and have some enjoyable reading while sitting in your favorite armchair by the fireplace during the long winter evenings 🙂


Updated 09/30/2008: Now the script not only collects the about_*.txt files, but it also includes the content of cmdlet help. It is also more localization-friendly. (Thanks to Markus for his brilliant CDATA suggestion!)




# Get-Manual.ps1

# This script merges the text from all about* files
# in the Windows PowerShell installation directory ($pshome)
# and help content from cmdlet help
# into one MS Word document file and opens the file that was created.

# Setting up helper functions.

function MakeHeading($text)
 return ‘<w:p><w:pPr><w:pStyle w:val=”Heading1″ /></w:pPr><w:r><w:t><![CDATA[‘ + $text + ‘]]></w:t></w:r></w:p>’

function MakeParagraph($text)
 return ‘<w:p><w:r><w:t><![CDATA[‘ + $text + ‘]]></w:t></w:r></w:p>’

# Set the file name for generated WordML document.
$doc = “PowerShell Get-Help Content.doc”

“Generating MS Word document…”

$sb=new-object system.text.stringbuilder

$null = $sb.Append(@’
<?xml version=”1.0″ encoding=”UTF-8″ standalone=”yes” ?>
<?mso-application progid=”Word.Document”?>
 w:macrosPresent=”no” w:embeddedObjPresent=”no” w:ocxPresent=”no” xml:space=”preserve”>
  <w:versionOfBuiltInStylenames w:val=”4″ />
  <w:style w:type=”paragraph” w:default=”on” w:styleId=”Normal”>
   <w:name w:val=”Normal” />
    <w:rFonts w:ascii=”Lucida Console” w:h-ansi=”Lucida Console” w:cs=”Lucida Console” />
    <w:sz w:val=”24″ />
    <w:sz-cs w:val=”24″ />
    <w:lang w:val=”EN-US” w:fareast=”ZH-CN” w:bidi=”AR-SA” />
  <w:style w:type=”paragraph” w:styleId=”Heading1″>
   <w:name w:val=”heading 1″ />
   <wx:uiName wx:val=”Heading 1″ />
   <w:basedOn w:val=”Normal” />
   <w:next w:val=”Normal” />
    <w:pStyle w:val=”Heading1″ />
    <w:keepNext />
    <w:spacing w:before=”240″ w:after=”120″ />
    <w:outlineLvl w:val=”0″ />
    <w:b />
    <w:b-cs />
    <w:kern w:val=”32″ />
    <w:sz w:val=”32″ />
    <w:sz-cs w:val=”32″ />
  <w:view w:val=”web”/>
  <w:zoom w:val=”full-page” w:percent=”100″/>

# Get all content from about* help files.
$filter = “about*.txt”
dir $pshome -filter $filter -recurse | %{
 $null = $sb.Append((MakeHeading($_)))
 get-content $_.FullName | %{
  $null = $sb.Append((MakeParagraph($_)))

# Get all content from cmdlet help.
get-command | %{
 $null = $sb.Append((MakeHeading($_.Name + ‘ Cmdlet’)))

 $helpText = $_ | get-help -full | Out-String

 if ($helpText -eq “”) { $helpText= ‘<no help found>’ }

 $helpText -split “`n” | %{
  $null = $sb.Append((MakeParagraph($_)))

$null = $sb.Append(“</w:body></w:wordDocument>”)

# Write generated string to document file.
$sb.ToString() | out-file $doc -encoding UTF8

# Open the resulting file in MS-Word.
$null = [System.Diagnostics.Process]::Start(“$pwd\$doc”)




Vladimir Averkin

Windows PowerShell Test


Discussion is closed.

Feedback usabilla icon