PoshCode Logo PowerShell Code Repository

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

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