PoshCode Logo PowerShell Code Repository

Compile-Help by John Robbins 4 years ago (modification of post by Jeff Hillman view diff)
View followups from Robbie Wiley | diff | embed code: <script type="text/javascript" src="http://PoshCode.org/embed/144"></script>download | new post

This script uses the text and XML PowerShell help files to generate HTML help for all PowerShell Cmdlets, PSProviders, and “about” topics. the help topics are compiled into a .chm file using HTML Help Workshop.

  1. # Compile-Help.ps1
  2. # by Jeff Hillman
  3. #
  4. # this script uses the text and XML PowerShell help files to generate HTML help
  5. # for all PowerShell Cmdlets, PSProviders, and "about" topics.  the help topics
  6. # are compiled into a .chm file using HTML Help Workshop.
  7. #
  8. # Minor tweak by John Robbins to work on x64 when looking for HHC.EXE.
  9.  
  10. param( [string] $outDirectory = ".\PSHelp", [switch] $GroupByPSSnapIn )
  11.  
  12. function Html-Encode( [string] $value )
  13. {
  14.     # System.Web.HttpUtility.HtmlEncode() doesn't quite get everything, and
  15.     # I don't want to load the System.Web assembly just for this.  I'm sure
  16.     # I missed something here, but these are the characters I saw that needed
  17.     # to be encoded most often
  18.     $value = $value -replace "&(?![\w#]+;)", "&amp;"
  19.     $value = $value -replace "<(?!!--)", "&lt;"
  20.     $value = $value -replace "(?<!--)>", "&gt;"
  21.     $value = $value -replace "’", "&#39;"
  22.     $value = $value -replace '["“”]', "&quot;"
  23.    
  24.     $value = $value -replace "\n", "<br />"
  25.  
  26.     $value
  27. }
  28.  
  29. function Capitalize-Words( [string] $value )
  30. {
  31.     $capitalizedString = ""
  32.  
  33.     # convert the string to lower case and split it into individual words. for each one,
  34.     # capitalize the first character, and append it to the converted string
  35.     [regex]::Split( $value.ToLower(), "\s" ) | ForEach-Object {
  36.         $capitalizedString += ( [string]$_.Chars( 0 ) ).ToUpper() + $_.SubString( 1 ) + " "
  37.     }
  38.  
  39.     $capitalizedString.Trim()
  40. }
  41.  
  42. function Get-ParagraphedHtml( [string] $xmlText )
  43. {
  44.     $value = ""
  45.    
  46.     if ( $xmlText -match "<(\w+:)?para" )
  47.     {
  48.         $value = ""
  49.         $options = [System.Text.RegularExpressions.RegexOptions]::Singleline
  50.  
  51.         foreach ( $match in [regex]::Matches( $xmlText,
  52.             "<(?:\w+:)?para[^>]*>(?<Text>.*?)</(?:\w+:)?para>", $options ) )
  53.         {
  54.             $value += "<p>$( Html-Encode $match.Groups[ 'Text' ].Value )</p>"    
  55.         }
  56.     }
  57.     else
  58.     {
  59.         $value = Html-Encode $xmlText
  60.     }
  61.    
  62.     $value
  63. }
  64.  
  65. function Get-SyntaxHtml( [xml] $syntaxXml )
  66. {
  67.     $syntaxHtml = ""
  68.  
  69.     # generate the HTML for each form of the Cmdlet syntax
  70.     foreach ( $syntaxItem in $syntaxXml.syntax.syntaxItem )
  71.     {
  72.         if ( $syntaxHtml -ne "" )
  73.         {
  74.             $syntaxHtml += "<br /><br />`n"
  75.         }
  76.  
  77.         $syntaxHtml += "        $( $syntaxItem.name.get_InnerText().Trim() ) "
  78.  
  79.         if ( $syntaxItem.parameter )
  80.         {
  81.             foreach ( $parameter in $syntaxItem.parameter )
  82.             {
  83.                 $required = [bool]::Parse( $parameter.required )
  84.  
  85.                 $syntaxHtml += "<nobr>[-$( $parameter.name.get_InnerText().Trim() )"
  86.  
  87.                 if ( $required )
  88.                 {
  89.                     $syntaxHtml += "]"
  90.                 }
  91.  
  92.                 if ( $parameter.parameterValue )
  93.                 {
  94.                     $syntaxHtml +=
  95.                         " &lt;$( $parameter.parameterValue.get_InnerText().Trim() )&gt;"
  96.                 }
  97.  
  98.                 if ( !$required )
  99.                 {
  100.                     $syntaxHtml += "]"
  101.                 }
  102.  
  103.                 $syntaxHtml += "</nobr> "
  104.             }
  105.         }
  106.  
  107.         $syntaxHtml += " <nobr>[&lt;CommonParameters&gt;]</nobr>"
  108.     }
  109.  
  110.     $syntaxHtml.Trim()
  111. }
  112.  
  113. function Get-ParameterHtml( [xml] $parameterXml )
  114. {
  115.     $parameterHtml = ""
  116.  
  117.     # generate HTML for each parameter
  118.     foreach ( $parameter in $parameterXml.parameters.parameter )
  119.     {
  120.         if ( $parameterHtml -ne "" )
  121.         {
  122.             $parameterHtml += "        <br /><br />`n"
  123.         }
  124.  
  125.         $parameterHtml +=
  126.             "        <nobr><span class=`"boldtext`">-$( $parameter.name.get_InnerText().Trim() )"
  127.  
  128.         if ( $parameter.parameterValue )
  129.         {
  130.             $parameterHtml += " &lt;$( $parameter.parameterValue.get_InnerText().Trim() )&gt;"
  131.         }
  132.  
  133.         $parameterHtml += "</span></nobr>`n"
  134.  
  135.         $parameterHtml += @"
  136.        <br />
  137.        <div id="contenttext">
  138.          $( Get-ParagraphedHtml $parameter.description.get_InnerXml().Trim() )
  139.  
  140. "@
  141.         if ( $parameter.possibleValues )
  142.         {
  143.             foreach ( $possibleValue in $parameter.possibleValues.possibleValue )
  144.             {
  145.                 $parameterHtml += @"
  146.          $( $possibleValue.value.Trim() )<br />
  147.  
  148. "@
  149.                 if ( $possibleValue.description.get_InnerText().Trim() -ne "" )
  150.                 {
  151.                     $parameterHtml += @"
  152.          <div id="contenttext">
  153.            $( Get-ParagraphedHtml $possibleValue.description.get_InnerXml().Trim() )
  154.          </div>
  155.  
  156. "@
  157.                 }
  158.             }
  159.         }
  160.        
  161.         $parameterHtml += @"
  162.        <br />
  163.        </div>
  164.        <table class="parametertable">
  165.          <tr>
  166.            <td>Required</td>
  167.            <td>$( $parameter.required )</td>
  168.          </tr>
  169.          <tr>
  170.            <td>Position</td>
  171.            <td>$( $parameter.position )</td>
  172.          </tr>
  173.          <tr>
  174.            <td>Accepts pipeline input</td>
  175.            <td>$( $parameter.pipelineInput )</td>
  176.          </tr>
  177.          <tr>
  178.            <td>Accepts wildcard characters</td>
  179.            <td>$( $parameter.globbing )</td>
  180.          </tr>
  181.  
  182. "@
  183.  
  184.         if ( $parameter.defaultValue )
  185.         {
  186.             if( $parameter.defaultValue.get_InnerText().Trim() -ne "" )
  187.             {
  188.                 $parameterHtml += @"
  189.          <tr>
  190.            <td>Default Value</td>
  191.            <td>$( $parameter.defaultValue.get_InnerText().Trim() )</td>
  192.          </tr>
  193.  
  194. "@
  195.             }
  196.         }
  197.  
  198.         $parameterHtml += @"
  199.        </table>
  200.  
  201. "@
  202.     }
  203.  
  204.     if ( $parameterHtml -ne "" )
  205.     {
  206.         $parameterHtml += "        <br /><br />`n"
  207.     }
  208.  
  209.     $parameterHtml += @"
  210.        <nobr><span class="boldtext">&lt;CommonParameters&gt;</span></nobr>
  211.        <br />
  212.        <div id="contenttext">
  213.          <p>
  214.            For more information about common parameters, type "Get-Help about_commonparameters".
  215.          </p>
  216.        </div>
  217.  
  218. "@
  219.  
  220.     $parameterHtml.Trim()
  221. }
  222.  
  223. function Get-InputHtml( [xml] $inputXml )
  224. {
  225.     $inputHtml = ""
  226.     $inputCount = 0
  227.  
  228.     # generate HTML for each input type
  229.     foreach ( $inputType in $inputXml.inputTypes.inputType )
  230.     {
  231.         if ( $inputHtml -ne "" )
  232.         {
  233.             $inputHtml += "        <br /><br />`n"
  234.         }
  235.  
  236.         if ( $inputType.type.name.get_InnerText().Trim() -ne "" -or
  237.             $inputType.type.description.get_InnerText().Trim() -ne "" )
  238.         {
  239.             $inputHtml += "      $( $inputType.type.name.get_InnerText().Trim() )`n"
  240.             $inputHtml += @"
  241.      <div id="contenttext">
  242.        $( Get-ParagraphedHtml $inputType.type.description.get_InnerXml().Trim() )
  243.      </div>
  244.  
  245. "@
  246.             $inputCount++
  247.         }
  248.     }
  249.  
  250.     $inputHtml.Trim()
  251.     $inputCount
  252. }
  253.  
  254. function Get-ReturnHtml( [xml] $returnXml )
  255. {
  256.     $returnHtml = ""
  257.     $returnCount = 0
  258.  
  259.     # generate HTML for each return value
  260.     foreach ( $returnValue in $returnXml.returnValues.returnValue )
  261.     {
  262.         if ( $returnHtml -ne "" )
  263.         {
  264.             $returnHtml += "        <br /><br />`n"
  265.         }
  266.  
  267.         if ( $returnValue.type.name.get_InnerText().Trim() -ne "" -or
  268.             $returnValue.type.description.get_InnerText().Trim() -ne "" )
  269.         {
  270.             $returnHtml += "      $( $returnValue.type.name.get_InnerText().Trim() )`n"
  271.             $returnHtml += @"
  272.      <div id="contenttext">
  273.        $( Get-ParagraphedHtml $returnValue.type.description.get_InnerXml().Trim() )
  274.      </div>
  275.  
  276. "@
  277.             $returnCount++
  278.         }
  279.     }
  280.  
  281.     $returnHtml.Trim()
  282.     $returnCount
  283. }
  284.  
  285. function Get-ExampleHtml( [xml] $exampleXml )
  286. {
  287.     $exampleHtml = ""
  288.     $exampleTotalCount = 0
  289.     $exampleCount = 0
  290.  
  291.     foreach ( $example in $exampleXml.examples.example )
  292.     {
  293.         $exampleTotalCount++
  294.     }
  295.  
  296.     # generate HTML for each example
  297.     foreach ( $example in $exampleXml.examples.example )
  298.     {
  299.         if ( $example.code -and $example.code.get_InnerText().Trim() -ne "" )
  300.         {
  301.             if ( $exampleHtml -ne "" )
  302.             {
  303.                 $exampleHtml += "        <br />`n"
  304.             }
  305.    
  306.             if ( $exampleTotalCount -gt 1 )
  307.             {
  308.                 $exampleHtml +=
  309.                     "        <nobr><span class=`"boldtext`">Example $( $exampleCount + 1 )</span></nobr>`n"
  310.             }
  311.    
  312.             $exampleCodeHtml = "$( Html-Encode $example.introduction.get_InnerText().Trim() )" +
  313.                 "$( Html-Encode $example.code.get_InnerText().Trim() )"
  314.            
  315.             $exampleHtml += "        <div class=`"syntaxregion`">$exampleCodeHtml</div>`n"
  316.  
  317.             $foundFirstPara = $false
  318.    
  319.             foreach ( $para in $example.remarks.para )
  320.             {
  321.                 if ( $para.get_InnerText().Trim() -ne "" )
  322.                 {
  323.                     # the first para is generally the description of the example.
  324.                     # other para tags usually contain sample output
  325.                     if ( !$foundFirstPara )
  326.                     {
  327.                         $exampleHtml += @"
  328.        <div id="contenttext">
  329.          <p>
  330.            $( Html-Encode $para.get_InnerText().Trim() )
  331.          </p>
  332.        </div>
  333.  
  334. "@
  335.                         $foundFirstPara = $true
  336.                     }
  337.                     else
  338.                     {
  339.                         $exampleHtml += @"
  340.        <pre class="syntaxregion">$( $( ( Html-Encode $para.get_InnerText().Trim() )  -replace "<br />", "`n" ) )</pre>
  341.  
  342. "@
  343.                     }
  344.                 }
  345.             }
  346.    
  347.             $exampleCount++
  348.         }
  349.     }
  350.  
  351.     $exampleHtml.Trim()
  352.     $exampleCount
  353. }
  354.  
  355. function Get-TaskExampleHtml( [xml] $exampleXml )
  356. {
  357.     $exampleHtml = ""
  358.     $exampleCount = 0
  359.     $exampleTotalCount = 0
  360.  
  361.     foreach ( $example in $exampleXml.examples.example )
  362.     {
  363.         $exampleTotalCount++
  364.     }
  365.  
  366.     # generate HTML for each example
  367.     foreach ( $example in $exampleXml.examples.example )
  368.     {
  369.         if ( $exampleHtml -ne "" )
  370.         {
  371.             $exampleHtml += "        <br />`n"
  372.         }
  373.  
  374.         if ( $exampleTotalCount -gt 1 )
  375.         {
  376.             $exampleHtml += "        <nobr><span class=`"boldtext`">Example $( $exampleCount + 1 )</span></nobr>`n"
  377.         }
  378.  
  379.         $exampleHtml += "        <div>$( Get-ParagraphedHtml $example.introduction.get_InnerXml().Trim() )</div>`n"
  380.        
  381.         $exampleCodeHtml = ( Html-Encode $example.code.Trim() ) -replace "<br />", "`n"
  382.  
  383.         $exampleHtml += "        <pre class=`"syntaxregion`">$exampleCodeHtml</pre>"
  384.  
  385.         $exampleHtml += "        <div>$( Get-ParagraphedHtml $example.remarks.get_InnerXml().Trim() )</div>`n"
  386.  
  387.         $exampleCount++
  388.     }
  389.  
  390.     $exampleHtml.Trim()
  391. }
  392.  
  393. function Get-LinkHtml( [xml] $linkXml )
  394. {
  395.     $linkHtml = ""
  396.     $linkCount = 0
  397.  
  398.     # generate HTML for each related link
  399.     foreach ( $navigationLink in $linkXml.relatedLinks.navigationLink )
  400.     {
  401.         if ( $navigationLink.linkText -and `
  402.             ( $helpHash.Keys | Foreach-Object { $_.ToUpper() } ) -contains $navigationLink.linkText.Trim().ToUpper() )
  403.         {
  404.             $linkHtml += "        $( $navigationLink.linkText.Trim() )<br />`n"
  405.             $linkCount++
  406.         }
  407.     }
  408.  
  409.     $linkHtml.Trim()
  410.     $linkCount
  411. }
  412.  
  413. function Get-TaskHtml( [xml] $taskXml )
  414. {
  415.     $taskHtml = ""
  416.     $taskCount = 0
  417.  
  418.     foreach ( $task in $taskXml.tasks.task )
  419.     {
  420.         if ( $taskHtml -ne "" )
  421.         {
  422.             $taskHtml += "        <br />`n"
  423.         }
  424.  
  425.         $taskHtml += "        <nobr><span class=`"boldtext`">Task:</span> $( $task.title.Trim() )</nobr>`n"
  426.        
  427.         $taskDescriptionHtml = ( Get-ParagraphedHtml $task.description.get_InnerXml().Trim() )
  428.        
  429.         $taskHtml += "        <div id=`"contenttext`">$taskDescriptionHtml</div>`n"
  430.  
  431.         # add the example sections
  432.         if ( $task.examples )
  433.         {
  434.             $taskHtml += @"
  435.        <div id="contenttext">
  436.          <p>
  437.            $( Get-TaskExampleHtml ( [xml]$task.examples.get_OuterXml() ) )
  438.          </p>
  439.        </div>
  440.    
  441. "@
  442.         }
  443.  
  444.         $taskCount++
  445.     }
  446.    
  447.     $taskHtml.Trim()
  448.     $taskCount
  449. }
  450.  
  451. function Get-DynamicParameterHtml( [xml] $dynamicParameterXml )
  452. {
  453.     $dynamicParameterHtml = ""
  454.    
  455.     # generate HTML for each dynamic parameter
  456.     foreach ( $dynamicParameter in $dynamicParameterXml.dynamicparameters.dynamicparameter )
  457.     {
  458.         $dynamicParameterHtml += "        <nobr><span class=`"boldtext`">-$( $dynamicParameter.name.Trim() )"
  459.  
  460.         if ( $dynamicParameter.type )
  461.         {
  462.             $dynamicParameterHtml += " &lt;$( $dynamicParameter.type.name.Trim() )&gt;"
  463.         }
  464.  
  465.         $dynamicParameterHtml += "</span></nobr>`n"
  466.  
  467.         $dynamicParameterHtml += @"
  468.        <br />
  469.        <div id="contenttext">
  470.          <p>
  471.            $( Html-Encode $dynamicParameter.description.Trim() )
  472.          </p>
  473.  
  474. "@
  475.         if ( $dynamicParameter.possiblevalues )
  476.         {
  477.             foreach ( $possibleValue in $dynamicParameter.possiblevalues.possiblevalue )
  478.             {
  479.                 $dynamicParameterHtml += @"
  480.          <div id="contenttext">
  481.            <span class=`"boldtext`">$( $possibleValue.value )</span>
  482.            <div id="contenttext">
  483.              $( Get-ParagraphedHtml $possibleValue.description.get_InnerXml().Trim() )
  484.            </div>
  485.          </div>
  486.  
  487. "@
  488.             }
  489.         }
  490.  
  491.         $dynamicParameterHtml += @"
  492.          <br />
  493.          <span class=`"boldtext`">Cmdlets Supported</span>
  494.          <div id="contenttext">
  495.            <p>
  496.              $( Html-Encode $dynamicParameter.cmdletsupported.Trim() )
  497.            </p>
  498.          </div>
  499.        </div>
  500.        <br />
  501.  
  502. "@
  503.     }
  504.  
  505.     $dynamicParameterHtml.Trim()
  506. }
  507.  
  508. function Write-AboutTopic( [string] $topicName, [string] $topicPath )
  509. {
  510.     # just dump the contents of the about topic exactly as it is.  the only changes needed
  511.     # are to encode the special HTML characters and add topic links
  512.     $topicHtml = @"
  513. <html>
  514.  <head>
  515.    <link rel="stylesheet" type="text/css" href="powershell.css" />
  516.    <title>About $( Capitalize-Words ( $topicName -replace "(about)?_", " " ).Trim() )</title>
  517.  </head>
  518.  <body>
  519.    <div id="topicheading">
  520.      <div id="topictitle">PowerShell Help</div>
  521.      About $( Capitalize-Words ( $topicName -replace "(about)?_", " " ).Trim() )
  522.    </div>
  523.    <pre>
  524. $( ( Html-Encode ( [string]::Join( [Environment]::NewLine, ( Get-Content -Path $topicPath ) ) ) ) -replace "<br />" )
  525.    </pre>
  526.  </body>
  527. </html>
  528. "@
  529.  
  530.     $topicHtml = Add-Links $topicName $topicHtml
  531.  
  532.     Out-File -FilePath "$outDirectory\Topics\$topicName.html" -Encoding Ascii -Input $topicHtml
  533. }
  534.  
  535. function Write-ProviderTopic( [string] $providerFullName, [xml] $providerXml )
  536. {
  537.     $providerName = $providerXml.providerhelp.Name.Trim()
  538.    
  539.     $topicHtml = @"
  540. <html>
  541.  <head>
  542.    <link rel="stylesheet" type="text/css" href="powershell.css" />
  543.    <title>$providerName Help</title>
  544.  </head>
  545.  <body>
  546.    <div id="topicheading">
  547.      <div id="topictitle">PowerShell Help</div>
  548.      $providerName Provider
  549.      <div style="text-align: right; padding-right: 3px;">
  550.         $( $providerFullName -replace "^\w+\." )
  551.      </div>
  552.    </div>
  553.    <div class="categorytitle">Drives</div>
  554.    <div id="contenttext">
  555.      $( Get-ParagraphedHtml $providerXml.providerhelp.drives.get_InnerXml().Trim() )
  556.    </div>
  557.    <div class="categorytitle">Synopsis</div>
  558.    <div id="contenttext">
  559.      <p>$( Html-Encode $providerXml.providerhelp.synopsis.Trim() )</p>
  560.    </div>
  561.  
  562. "@
  563.    
  564.     $topicHtml += @"
  565.    <div class="categorytitle">Description</div>
  566.    <div id="contenttext">
  567.      $( Get-ParagraphedHtml $providerXml.providerhelp.detaileddescription.get_InnerXml().Trim() )
  568.    </div>
  569.  
  570. "@
  571.  
  572.     if ( $providerXml.providerhelp.capabilities.get_InnerText().Trim() -ne "" )
  573.     {
  574.         $topicHtml += @"
  575.    <div class="categorytitle">Capabilities</div>
  576.    <div id="contenttext">
  577.      $( Get-ParagraphedHtml $providerXml.providerhelp.capabilities.get_InnerXml().Trim() )
  578.    </div>
  579.  
  580. "@
  581.     }
  582.  
  583.     $taskHtml, $taskCount = Get-TaskHtml( $providerXml.providerhelp.tasks.get_OuterXml() )
  584.    
  585.     if ( $taskCount -gt 0 )
  586.     {
  587.         $topicHtml += @"
  588.    <div class="categorytitle">Task$( if ( $taskCount -gt 1 ) { "s" } )</div>
  589.    <div id="contenttext">
  590.      $taskHtml
  591.    </div>
  592.  
  593. "@
  594.     }
  595.  
  596.     if ( $providerXml.providerhelp.dynamicparameters )
  597.     {
  598.         $topicHtml += @"
  599.    <div class="categorytitle">Dynamic Parameters</div>
  600.    <div id="contenttext">
  601.      $( Get-DynamicParameterHtml( $providerXml.providerhelp.dynamicparameters.get_OuterXml() ) )
  602.    </div>
  603.  
  604. "@
  605.     }
  606.  
  607.     if ( $providerXml.providerhelp.notes.Trim() -ne "" )
  608.     {
  609.         $topicHtml += @"
  610.    <div class="categorytitle">Notes</div>
  611.    <div id="contenttext">
  612.      <p>$( Html-Encode $providerXml.providerhelp.notes.Trim() )</p>
  613.    </div>
  614.  
  615. "@
  616.     }
  617.  
  618.     $topicHtml += @"
  619.    <div class="categorytitle">Related Links</div>
  620.    <div id="contenttext">
  621.      <p>$( Html-Encode $providerXml.providerhelp.relatedlinks.Trim() )</p>
  622.    </div>
  623.    <br />
  624.  </body>
  625. </html>    
  626. "@    
  627.  
  628.     $topicHtml = Add-Links $providerName $topicHtml
  629.  
  630.     Out-File -FilePath "$outDirectory\Topics\$providerFullName.html" -Encoding Ascii -Input $topicHtml
  631. }
  632.  
  633. function Write-CmdletTopic( [string] $cmdletFullName, [xml] $cmdletXml )
  634. {
  635.     $cmdletName = $cmdletXml.command.details.name.Trim()
  636.    
  637.     # add the heading, syntax section, and description
  638.     $topicHtml = @"
  639. <html>
  640.  <head>
  641.    <link rel="stylesheet" type="text/css" href="powershell.css" />
  642.    <title>$cmdletName Help</title>
  643.  </head>
  644.  <body>
  645.    <div id="topicheading">
  646.      <div id="topictitle">PowerShell Help</div>
  647.      $cmdletName Cmdlet
  648.      <div style="text-align: right; padding-right: 3px;">
  649.         $( $cmdletFullName -replace "^\w+-\w+\." )
  650.      </div>
  651.    </div>
  652.    <div class="categorytitle">Synopsis</div>
  653.    <div id="contenttext">
  654.      $( Get-ParagraphedHtml $cmdletXml.command.details.description.get_InnerXml().Trim() )
  655.    </div>
  656.    <div class="categorytitle">Syntax</div>
  657.    <div id="contenttext">
  658.      <div class="syntaxregion">$( Get-SyntaxHtml ( [xml]$cmdletXml.command.syntax.get_OuterXml() ) )</div>
  659.    </div>
  660.    <div class="categorytitle">Description</div>
  661.    <div id="contenttext">
  662.      $( Get-ParagraphedHtml $cmdletXml.command.description.get_InnerXml().Trim() )
  663.    </div>
  664.  
  665. "@
  666.  
  667.     # add the parameters section
  668.     if ( $cmdletXml.command.parameters )
  669.     {
  670.         $topicHtml += @"
  671.    <div class="categorytitle">Parameters</div>
  672.    <div id="contenttext">
  673.      <p>
  674.        $( Get-ParameterHtml ( [xml]$cmdletXml.command.parameters.get_OuterXml() ) )
  675.      </p>
  676.    </div>
  677.  
  678. "@
  679.     }
  680.     else
  681.     {
  682.         $topicHtml += @"
  683.    <div class="categorytitle">Parameters</div>
  684.    <div id="contenttext">
  685.      <p>
  686.       <nobr><span class="boldtext">&lt;CommonParameters&gt;</span></nobr><br />
  687.       <div id="contenttext">
  688.         <p>
  689.            For more information about common parameters, type "Get-Help about_commonparameters".
  690.         </p>
  691.        </div>
  692.      </p>
  693.    </div>
  694.  
  695. "@
  696.     }
  697.  
  698.     # add the input types section
  699.     if ( $cmdletXml.command.inputTypes )
  700.     {
  701.         $inputHtml, $inputCount = Get-InputHtml ( [xml]$cmdletXml.command.inputTypes.get_OuterXml() )
  702.    
  703.         if ( $inputCount -gt 0 )
  704.         {
  705.             $topicHtml += @"
  706.    <div class="categorytitle">Input Type$( if ( $inputCount -gt 1 ) { "s" } )</div>
  707.    <div id="contenttext">
  708.      $inputHtml
  709.    </div>
  710.  
  711. "@
  712.         }
  713.     }
  714.  
  715.     # add the return values section
  716.     if ( $cmdletXml.command.returnValue )
  717.     {
  718.         $returnHtml, $returnCount = Get-ReturnHtml ( [xml]$cmdletXml.command.returnValues.get_OuterXml() )
  719.    
  720.         if ( $returnCount -gt 0 )
  721.         {
  722.             $topicHtml += @"
  723.    <div class="categorytitle">Return Value$( if ( $returnCount -gt 1 ) { "s" } )</div>
  724.    <div id="contenttext">
  725.      $returnHtml
  726.    </div>
  727.  
  728. "@
  729.         }
  730.     }
  731.  
  732.     # add the notes section
  733.     if ( $cmdletXml.command.alertSet )
  734.     {
  735.         if ( $cmdletXml.command.alertSet.get_InnerText().Trim() -ne "" )
  736.         {
  737.             $topicHtml += @"
  738.    <div class="categorytitle">Notes</div>
  739.    <div id="contenttext">
  740.      $( Get-ParagraphedHtml $cmdletXml.command.alertSet.get_InnerXml().Trim() )
  741.    </div>
  742.  
  743. "@
  744.         }
  745.     }
  746.  
  747.     # add the example section
  748.     if ( $cmdletXml.command.examples )
  749.     {
  750.         $exampleHtml, $exampleCount = Get-ExampleHtml ( [xml]$cmdletXml.command.examples.get_OuterXml() )
  751.  
  752.         if ( $exampleCount -gt 0 )
  753.         {
  754.             $topicHtml += @"
  755.    <div class="categorytitle">Example$( if ( $exampleCount -gt 1 ) { "s" } )</div>
  756.    <div id="contenttext">
  757.      <p>
  758.        $exampleHtml
  759.      </p>
  760.    </div>
  761.  
  762. "@
  763.         }
  764.     }
  765.  
  766.     # add the related links section
  767.     if ( $cmdletXml.command.relatedLinks )
  768.     {
  769.         $linkHtml, $linkCount = Get-LinkHtml ( [xml]$cmdletXml.command.relatedLinks.get_OuterXml() )
  770.  
  771.         if ( $linkCount -gt 0 )
  772.         {
  773.             $topicHtml += @"
  774.    <div class="categorytitle">Related Link$( if ( $linkCount -gt 1 ) { "s" } )</div>
  775.    <div id="contenttext">
  776.      <p>
  777.        $linkHtml
  778.      </p>
  779.    </div>
  780.    <br />
  781.  
  782. "@
  783.         }
  784.         else
  785.         {
  786.             $topicHtml +=  "        <br />`n"
  787.         }
  788.     }
  789.     else
  790.     {
  791.         $topicHtml +=  "        <br />`n"
  792.     }
  793.  
  794.     $topicHtml += @"
  795.  </body>
  796. </html>
  797. "@
  798.  
  799.     $topicHtml = Add-Links $cmdletName $topicHtml
  800.  
  801.     Out-File -FilePath "$outDirectory\Topics\$cmdletFullName.html" -Encoding Ascii -Input $topicHtml
  802. }
  803.  
  804. function Add-Links( [string] $topicName, [string] $topicHtml )
  805. {
  806.     # we only want to add links for Cmdlets and about topics
  807.     $helpHash.Keys | Where-Object { $_ -match "(^\w+-\w+|^about_)" } | Foreach-Object {
  808.         $searchText = $_
  809.    
  810.         # keys representing Cmdlets are formatted like this:
  811.         # <Cmdlet Name>.<PSProvider name>
  812.         if ( $_ -match "^\w+-\w+" )
  813.         {
  814.             # we only want to search for the Cmdlet name
  815.             $searchText = $matches[ 0 ]
  816.         }
  817.  
  818.         # if the search text isn't the topic being processed
  819.         if ( $searchText -ne $topicName )
  820.         {
  821.             $topicHtml = $topicHtml -replace "\b($searchText)\b", "<a href=`"Topics\$_.html`"><nobr>`$1</nobr></a>"
  822.         }
  823.     }
  824.  
  825.     $topicHtml
  826. }
  827.  
  828. # file dumping functions
  829.  
  830. function Write-Hhp
  831. {
  832.     # write the contents of the Html Help Project file
  833.     Out-File -FilePath "$outDirectory\powershell.hhp" -Encoding Ascii -Input @"
  834. [OPTIONS]
  835. Binary TOC=Yes
  836. Compatibility=1.1 or later
  837. Compiled file=PowerShell.chm
  838. Contents file=powershell.hhc
  839. Default topic=Topics/default.html
  840. Full-text search=Yes
  841. Language=0x409 English (United States)
  842. Title=PowerShell Help
  843.  
  844. [INFOTYPES]
  845. "@
  846. }
  847.  
  848. function Write-DefaultPage
  849. {
  850.     $defaultHtml =  @"
  851. <html>
  852.  <head>
  853.    <link rel="stylesheet" type="text/css" href="powershell.css" />
  854.    <title>PowerShell Help</title>
  855.  </head>
  856.  <body style="margin: 5px 5px 5px 5px; color: #FFFFFF; background-color: #C86400;">
  857.     <h2>Windows PowerShell Help</h2>
  858.     <br />
  859.     This complied help manual contains the help for all of the built-in PowerShell Cmdlets
  860.     and PSProviders, as well as the help for any Cmdlets or PSProviders added through
  861.     Add-PSSnapin, if help for them is available.  Also included are all of the "about" topics.
  862.     <br /><br />
  863.     To use this manual from the PowerShell command line, add the following function and
  864.     alias to your PowerShell profile:
  865.     <div id="contenttext">
  866.       <pre class="syntaxregion">function Get-CompiledHelp( [string] `$topic )
  867. {
  868.     if ( `$topic )
  869.     {
  870.         # Get-Command will fail if the topic is a PSProvider or an "about" topic.
  871.         `$ErrorActionPreference = "SilentlyContinue"
  872.  
  873.         # we don't want Get-Command to resolve to an application or a function
  874.         `$command = Get-Command `$topic | Where-Object { `$_.CommandType -match "Alias|Cmdlet" }
  875.  
  876.         # if the topic is an alias or a Cmdlet, combine its name with
  877.         # its PSProvider to get the full name of the help file
  878.         if ( `$command -and `$command.CommandType -eq "Alias" )
  879.         {
  880.             `$topic = "`$( `$command.Definition ).`$( `$command.ReferencedCommand.PSSnapIn.Name )"
  881.         }
  882.         elseif ( `$command -and `$command.CommandType -eq "Cmdlet" )
  883.         {
  884.             `$topic = "`$( `$command.Name ).`$( `$command.PSSnapIn.Name )"
  885.         }
  886.         else
  887.         {
  888.             # check to see if we have a PSProvider
  889.             `$psProvider = Get-PSProvider `$topic
  890.  
  891.             if ( `$psProvider )
  892.             {
  893.                 `$topic = "`$( `$psProvider.Name ).`$( `$psProvider.PSSnapIn.Name )"
  894.             }
  895.         }
  896.  
  897.         hh.exe "mk:@MSITStore:$( Resolve-Path "$outDirectory" )\PowerShell.chm::/Topics/`$topic.html"
  898.     }
  899.     else
  900.     {
  901.         hh.exe "$( Resolve-Path "$outDirectory" )\PowerShell.chm"
  902.     }
  903. }
  904.  
  905. Set-Alias chelp Get-CompiledHelp</pre>
  906.     </div>
  907.     <br />
  908.     The path in the Get-CompliedHelp function corresponds to the location where this compiled
  909.     help manual was originally created.  If this file is moved to another location, the path
  910.     in the function will need to be updated.
  911.     <br />
  912.     <br />
  913.     To view the help topic for Get-ChildItem, type the following:
  914.     <div id="contenttext">
  915.       <div class="syntaxregion">PS$ Get-CompiledHelp Get-ChildItem</div>
  916.     </div>
  917.     <br />
  918.     Because "ls" is an alias for Get-ChildItem, and "chelp" is an alias for Get-CompliedHelp, the following also works:
  919.     <div id="contenttext">
  920.       <div class="syntaxregion">PS$ chelp ls</div>
  921.     </div>
  922.   </body>
  923. </html>
  924. "@
  925.  
  926.    $defaultHtml = Add-Links "" $defaultHtml
  927.  
  928.    Out-File -FilePath "$outDirectory\Topics\default.html" -Encoding Ascii -Input $defaultHtml
  929. }
  930.  
  931. function Write-Css
  932. {
  933.    Out-File -FilePath "$outDirectory\powershell.css" -Encoding Ascii -Input @"
  934. body
  935. {
  936.   margin: 0px 0px 0px 0px;
  937.   padding: 0px 0px 0px 0px;
  938.   font-family: Verdana, Arial, Helvetica, sans-serif;
  939.   font-size: 70%;
  940.   width: 100%;
  941. }
  942.  
  943. div#topicheading
  944. {
  945.   position: relative;
  946.   left: 0px;
  947.   padding: 5px 0px 5px 10px;
  948.   border-bottom: 1px solid #999999;
  949.   color: #FFFFFF;
  950.   background-color: #C86400;
  951.   font-size: 110%;
  952.   font-weight: bold;
  953.   text-align: left;
  954. }
  955.  
  956. div#topictitle
  957. {
  958.   padding: 5px 5px 5px 5px;
  959.   color: #FFFFFF
  960.   font-size: 90%;
  961.   font-weight: normal;
  962. }
  963.  
  964. div#contenttext
  965. {
  966.   top: 0px;
  967.   padding: 0px 25px 0px 25px;
  968. }
  969.  
  970. p { margin: 5px 0px 5px 0px; }
  971.  
  972. a:link    { color: #0000FF; }
  973. a:visited { color: #0000FF; }
  974. a:hover   { color: #3366FF; }
  975.  
  976. table.parametertable
  977. {
  978.   margin-left: 25px;
  979.   font-size: 100%;
  980.   border-collapse:collapse
  981. }
  982.  
  983. table.parametertable td
  984. {
  985.   font-size: 100%;
  986.   border: solid #999999 1px;
  987.   padding: 0in 5.4pt 0in 5.4pt
  988. }
  989.  
  990. pre.syntaxregion, div.syntaxregion
  991. {
  992.   background: #DDDDDD;
  993.   padding: 4px 8px;
  994.   cursor: text;
  995.   margin-top: 1em;
  996.   margin-bottom: 1em;
  997.   margin-left: .6em;
  998.   color: #000000;
  999.   border-width: 1px;
  1000.   border-style: solid;
  1001.   border-color: #999999;
  1002. }
  1003.  
  1004. .categorytitle
  1005. {
  1006.   padding-top: .8em;
  1007.   font-size: 110%;
  1008.   font-weight: bold;
  1009.   text-align: left;
  1010.   margin-left: 5px;
  1011. }
  1012.  
  1013. .boldtext { font-weight: bold; }
  1014. "@
  1015. }
  1016.  
  1017. ### main ###
  1018.  
  1019. # create the topics directory
  1020. New-Item -Type Directory -Path "$outDirectory" -Force | Out-Null
  1021. New-Item -Type Directory -Path "$outDirectory\Topics" -Force | Out-Null
  1022.  
  1023. "`nRetrieving help content...`n"
  1024.  
  1025. # initialize variables for HHC file
  1026. $hhcContentsHtml = ""
  1027. $cmdletCategoryHtml = ""
  1028. $cmdletCategoryHash = @{}
  1029.  
  1030. # help content hash
  1031. $helpHash = @{}
  1032.  
  1033. # get the Cmdlet help
  1034. Get-PSSnapIn | Sort-Object -Property Name | Foreach-Object {
  1035.    $psSnapInName = $_.Name
  1036.    
  1037.    $helpFilePath = Join-Path $_.ApplicationBase ( ( Get-Command -PSSnapIn $_ ) | Select-Object -First 1 ).HelpFile
  1038.    
  1039.    # the culture needs to be added to the path on Vista    
  1040.    if ( !( Test-Path $helpFilePath ) )
  1041.    {
  1042.        $helpFilePath = "$( $_.ApplicationBase )\$( $Host.CurrentUICulture.Name )\$( Split-Path -Leaf $helpFilePath )"
  1043.    }
  1044.  
  1045.    if ( Test-Path $helpFilePath )
  1046.    {
  1047.        $helpXml = [xml]( Get-Content $helpFilePath )
  1048.    
  1049.        $cmdletCategoryContents = ""
  1050.    
  1051.        Get-Command -PSSnapIn $_ | Foreach-Object {
  1052.            $commandName = $_.Name
  1053.    
  1054.            $helpXml.helpitems.command | Where-Object {
  1055.                $_.details.name -and $_.details.name.Trim() -imatch "\b$commandName\b"
  1056.            } | Foreach-Object {
  1057.                # add the Xml Help of the Cmdlet to the help hashtable
  1058.                $helpHash[ "{0}.{1}" -f $commandName, $psSnapInName ] = $_.get_OuterXml()
  1059.  
  1060.                $cmdletTopicItem = @"
  1061.           <li><object type="text/sitemap">
  1062.             <param name="Name" value="$commandName">
  1063.             <param name="Local" value="Topics\$( "{0}.{1}" -f $commandName, $psSnapInName ).html">
  1064.           </object>
  1065.  
  1066. "@
  1067.                if ( $GroupByPSSnapIn )
  1068.                {    
  1069.                    $cmdletCategoryContents += $cmdletTopicItem
  1070.                }
  1071.                else
  1072.                {
  1073.                    # save the topics so they can be sorted properly and added to the HHC later
  1074.                    $cmdletCategoryHash[ "{0}.{1}" -f $commandName, $psSnapInName ] = $cmdletTopicItem
  1075.                }
  1076.            }
  1077.        }
  1078.    
  1079.        if ( $GroupByPSSnapIn )
  1080.        {
  1081.            # add a category in the HHC for this PSSnapIn and its Cmdlets
  1082.            $cmdletCategoryHtml += @"
  1083.         <li><object type="text/sitemap">
  1084.           <param name="Name" value="$psSnapInName">
  1085.         </object>
  1086.         <ul>
  1087.           $( $cmdletCategoryContents.Trim() )
  1088.         </ul>
  1089.  
  1090. "@
  1091.        }
  1092.    }
  1093. }
  1094.  
  1095. # sort the Cmdlets so they are added to the HHC in a logical order
  1096. if ( !$GroupByPSSnapIn )
  1097. {
  1098.    $cmdletCategoryHash.Keys | Sort-Object | Foreach-Object {
  1099.        $cmdletCategoryHtml += $cmdletCategoryHash[ $_ ]
  1100.    }
  1101. }
  1102.  
  1103. # add the Cmdlet category to the HHC
  1104. $hhcContentsHtml += @"
  1105.       <li><object type="text/sitemap">
  1106.         <param name="Name" value="Cmdlet Help">
  1107.       </object>
  1108.       <ul>
  1109.         $( $cmdletCategoryHtml.Trim() )
  1110.       </ul>
  1111.  
  1112. "@
  1113.  
  1114. $providerCategoryHtml = ""
  1115. $providerCategoryHash = @{}
  1116.  
  1117. # get the PSProvider help
  1118. Get-PSSnapIn | Sort-Object -Property Name | Foreach-Object {
  1119.    $psSnapInName = $_.Name
  1120.  
  1121.    $helpFilePath = Join-Path $_.ApplicationBase ( ( Get-Command -PSSnapIn $_ ) | Select-Object -First 1 ).HelpFile
  1122.  
  1123.    # the culture needs to be added to the path on Vista    
  1124.    if ( !( Test-Path $helpFilePath ) )
  1125.    {
  1126.        $helpFilePath = "$( $_.ApplicationBase )\$( $Host.CurrentUICulture.Name )\$( Split-Path -Leaf $helpFilePath )"
  1127.    }
  1128.  
  1129.    if ( Test-Path $helpFilePath )
  1130.    {
  1131.        $helpXml = [xml]( Get-Content $helpFilePath )
  1132.        
  1133.        $providerCategoryContents = ""
  1134.  
  1135.        Get-PSProvider | Where-Object { $_.PSSnapin.Name -eq $psSnapInName } | Foreach-Object {
  1136.            $psProviderName = $_.Name
  1137.  
  1138.            $helpXml.helpitems.providerhelp |
  1139.            Where-Object { $_.name.Trim() -imatch "\b$psProviderName\b" } |
  1140.            Foreach-Object {
  1141.                $helpHash[ "{0}.{1}" -f $psProviderName, $psSnapInName ] = $_.get_OuterXml()
  1142.    
  1143.                # add a category in the HHC for this PSProvider
  1144.                $providerTopicItem = @"
  1145.         <li><object type="text/sitemap">
  1146.           <param name="Name" value="$psProviderName">
  1147.           <param name="Local" value="Topics\$( "{0}.{1}" -f $psProviderName, $psSnapInName ).html">
  1148.         </object>
  1149.  
  1150. "@
  1151.                if ( $GroupByPSSnapIn )
  1152.                {    
  1153.                    $providerCategoryContents += $providerTopicItem
  1154.                }
  1155.                else
  1156.                {
  1157.                    # save the topics so they can be sorted properly and added to the HHC later
  1158.                    $providerCategoryHash[ "{0}.{1}" -f $psProviderName, $psSnapInName ] = $providerTopicItem
  1159.                }
  1160.            }
  1161.        }
  1162.    
  1163.        if ( $GroupByPSSnapIn -and $providerCategoryContents -ne "" )
  1164.        {
  1165.            # add a category in the HHC for this PSSnapIn and its Cmdlets
  1166.            $providerCategoryHtml += @"
  1167.         <li><object type="text/sitemap">
  1168.           <param name="Name" value="$psSnapInName">
  1169.         </object>
  1170.         <ul>
  1171.           $( $providerCategoryContents.Trim() )
  1172.         </ul>
  1173.  
  1174. "@
  1175.        }
  1176.    }
  1177. }
  1178.  
  1179. # sort the PSProviders so they are added to the HHC in a logical order
  1180. if ( !$GroupByPSSnapIn )
  1181. {
  1182.    $providerCategoryHash.Keys | Sort-Object | Foreach-Object {
  1183.        $providerCategoryHtml += $providerCategoryHash[ $_ ]
  1184.    }
  1185. }
  1186.  
  1187. # add the PSProvider category to the HHC
  1188. $hhcContentsHtml += @"
  1189.       <li><object type="text/sitemap">
  1190.         <param name="Name" value="Provider Help">
  1191.       </object>
  1192.       <ul>
  1193.         $( $providerCategoryHtml.Trim() )
  1194.       </ul>
  1195.  
  1196. "@
  1197.  
  1198. # get the about topics
  1199. $about_TopicPaths = @()
  1200.  
  1201. $helpPath = ""
  1202.  
  1203. if ( Resolve-Path "$pshome\about_*.txt" )
  1204. {
  1205.    $helpPath = "$pshome"
  1206. }
  1207. elseif ( Resolve-Path "$pshome\$( $Host.CurrentUICulture.Name )\about_*.txt" )
  1208. {
  1209.    $helpPath = "$pshome\$( $Host.CurrentUICulture.Name )"
  1210. }
  1211.  
  1212. if ( Test-Path $helpPath )
  1213. {
  1214.    $about_TopicPaths += Get-ChildItem "$helpPath\about_*.txt"
  1215. }
  1216.  
  1217. # we SilentlyContinue with Get-ChildItem errors because the ModuleName
  1218. # for the built-in PSSnapins doesn't resolve to anything, since the assemblies
  1219. # are only in the GAC.
  1220. $about_TopicPaths += Get-PSSnapin | Foreach-Object {
  1221.    ( Get-ChildItem $_.ModuleName -ErrorAction "SilentlyContinue" ).DirectoryName
  1222. } | Foreach-Object {
  1223.    Get-ChildItem "$_\about_*.txt"
  1224. }
  1225.  
  1226. if ( $about_TopicPaths.Count -gt 0 )
  1227. {
  1228.    $aboutCategoryHtml = ""
  1229.    
  1230.    $about_TopicPaths | Sort-Object -Unique -Property @{ Expression = { $_.Name.ToUpper() } }| Foreach-Object {
  1231.        # pull the topic name out of the file name
  1232.        $name = ( $_.Name -replace "(.xml)?.help.txt", "`$1" )
  1233.    
  1234.        # add the path of the topic to the help hashtable
  1235.        $helpHash[ $name ] = $_.FullName
  1236.    
  1237.        $topicName = Capitalize-Words ( $name -replace "(about)?_", " " ).Trim()
  1238.    
  1239.        # add a category in the HHC for this about topic
  1240.        $aboutCategoryHtml += @"
  1241.         <li><object type="text/sitemap">
  1242.           <param name="Name" value="$topicName">
  1243.           <param name="Local" value="Topics\$name.html">
  1244.         </object>
  1245.  
  1246. "@
  1247.    }
  1248.  
  1249.    # add the About Topics category to the HHC
  1250.    $hhcContentsHtml += @"
  1251.       <li><object type="text/sitemap">
  1252.         <param name="Name" value="About Topics">
  1253.       </object>
  1254.       <ul>
  1255.         $( $aboutCategoryHtml.Trim() )
  1256.       </ul>
  1257.  
  1258. "@
  1259. }
  1260.  
  1261. # write the contents file
  1262. Out-File -FilePath "$outDirectory\powershell.hhc" -Encoding Ascii -Input @"
  1263. <!doctype html public "-//ietf//dtd html//en">
  1264. <html>
  1265.   <head>
  1266.     <meta name="Generator" content="Microsoft&reg; HTML Help Workshop 4.1">
  1267.     <!-- Sitemap 1.0 -->
  1268.   </head>
  1269.   <body>
  1270.     <object type="text/site properties">
  1271.       <param name="Window Styles" value="0x800025">
  1272.     </object>
  1273.     <ul>
  1274.       <li><object type="text/sitemap">
  1275.         <param name="Name" value="PowerShell Help">
  1276.         <param name="Local" value="Topics\default.html">
  1277.       </object>
  1278.       $( $hhcContentsHtml.Trim() )
  1279.     </ul>
  1280.   </body>
  1281. </html>
  1282. "@
  1283.  
  1284. $helpHash.Keys | Sort-Object | Foreach-Object {
  1285.    switch -regex ( $_ )
  1286.    {
  1287.        # about topic
  1288.        "about_"
  1289.        {
  1290.            "Creating help for the $_ about topic..."
  1291.            Write-AboutTopic $_ $helpHash[ $_ ]
  1292.        }
  1293.  
  1294.        # Verb-Noun: Cmdlet
  1295.        "\w+-\w+"
  1296.        {
  1297.            "Creating help for the $( $_ -replace '(^\w+-\w+).*', '$1' ) Cmdlet..."
  1298.            Write-CmdletTopic $_ $helpHash[ $_ ]
  1299.        }
  1300.        
  1301.        # PSProvider
  1302.        default
  1303.        {
  1304.            "Creating help for the $( $_ -replace '(^\w+).*', '$1' ) PSProvider..."
  1305.            Write-ProviderTopic $_ $helpHash[ $_ ]
  1306.        }
  1307.    }
  1308. }
  1309.  
  1310. Write-DefaultPage
  1311. Write-Css
  1312. Write-Hhp
  1313.  
  1314. $progDir = "C:\Program Files"
  1315. if ( $(Test-Path env:"ProgramFiles(x86)") -eq $True )
  1316. {
  1317.         $progDir = $(get-item env:"ProgramFiles(x86)").value
  1318. }
  1319. if ( Test-Path $prodDir + "\HTML Help Workshop\hhc.exe" )
  1320. {
  1321.    # compile the help
  1322.    "`nCompiling the help manual...`n"
  1323.    Push-Location
  1324.    Set-Location $outDirectory
  1325.    & $progDir + "\HTML Help Workshop\hhc.exe" powershell.hhp
  1326.    Pop-Location
  1327.    
  1328.    # open the help file
  1329.    & "$outDirectory\PowerShell.chm"
  1330. }
  1331. else
  1332. {
  1333.    Write-Host -ForegroundColor Red @"
  1334.  
  1335. HTML Help Workshop is not installed, or it was not installed in its default
  1336. location of "C:\Program Files [x86]\HTML Help Workshop".
  1337.  
  1338. HTML Help Workshop is required to compile the help manual.  It can be downloaded
  1339. free of charge from Microsoft:
  1340.  
  1341. http://www.microsoft.com/downloads/details.aspx?familyid=00535334-c8a6-452f-9aa0-d597d16580cc&displaylang=en
  1342.  
  1343. If you do not want to install HTML Help Workshop on this machine, all of the
  1344. files necessary to compile the manual have been created here:
  1345.  
  1346. $( Resolve-Path $outDirectory )
  1347.  
  1348. Copy these files to a machine with HTML Help Workshop, and you can compile the
  1349. manual there, with the following command:
  1350.  
  1351. <HTML Help Workshop location>\hhc.exe powershell.hhp
  1352.  
  1353. "@
  1354. }

Submit a correction or amendment below (
click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:


Remember me