#Import System.Web in order to use HtmlEncode functionality [System.Reflection.Assembly]::LoadWithPartialName("System.Web") | out-null function encode($str) { [System.web.httputility]::HtmlEncode($str).Trim() } function New-HtmlHelp { param($commands = $null, $outputDir = "./help", $title = "", [switch]$groupsnapins) $commandsHelp = $commands | sort-object name | get-help -full #create an output directory md $outputDir | Out-Null cp doc-style.css $outputDir #Generate frame page $frameFileName = $outputDir + "/index.html" "$title" | out-file -encoding ascii $frameFileName if ($groupsnapins) { ########################################################################## ## Gaurhoth Modification ########################################################################## # Left frame now includes two additional Frames (Top-Frame.html (Snapins) and Bottom-Frame.html (CmdLets). $leftFileName = $outputDir + "/left-frame.html" "Snapins" | out-file -encoding ascii $leftFileName # Top Left frame. Lists all snapins represented by cmdlets found in $commands' $SnapinFileName = $outputdir + "/top-frame.html" $SnapinData = "" $SnapinData += "All Cmdlets
" $commandshelp | sort pssnapin -unique | % { $name = encode($_.pssnapin) $snapinData += "$name
" } $snapinData += "" $snapinData | out-file -encoding ascii $SnapinFileName # Bottom Left frame. Lists all CmdLets in selected Snapin from Top Left Frame. $data = @{} $commandsHelp | % { $filename = $outputdir + "/" + $_.pssnapin $name = encode($_.name) $data[$($outputdir + "/All Cmdlets")] += "$name
" $data[$filename] += "$name
" } $data.keys | % { $data[$_] = "" + ` $data[$_] + "" $data[$_] | out-file -encoding ascii "$_.html" } } else { # Original left Frame by vmware #Generate index $indexFileName = $outputDir + "/left-frame.html" $indexData = "" foreach ($c in $commandsHelp) { $name = encode($c.Name) $indexData += "$name
" } $indexData += "" $indexData | out-file -encoding ascii $indexFileName } #Generate all single help files $outputText = $null foreach ($c in $commandsHelp) { $fileName = ( $outputDir + "/" + $c.Name + ".html" ) $data = "$(encode($c.Name))" # Name $data += "

$(encode($c.Name))

" # Synopsis $data += "

Synopsis

$(encode($c.synopsis))" # Syntax $data += "

Syntax

$(encode(&{$c.syntax | out-string -width 2000}))" # Related Commands $data += "

Related Commands

" foreach ($relatedLink in $c.relatedLinks.navigationLink) { if($relatedLink.linkText -ne $null -and $relatedLink.linkText.StartsWith("about") -eq $false){ $uri = "" if( $relatedLink.uri -ne "" ) { $uri = $relatedLink.uri } else{ $uri = $relatedLink.linkText } $data += "$(encode($relatedLink.linkText))
" } } # Detailed Description $data += "

Detailed Description

$(encode(&{$c.Description | out-string -width 2000}))" # Parameters $data += "

Parameters

" + "" + "" $paramNum = 0 $c.parameters.parameter | %{ $param = $_ $data += "" $data += "" $data += "" $data += "" } $data += "
NameDescriptionRequired?Pipeline InputDefault Value
$(encode($param.Name))$(encode(&{$param.Description | out-string -width 2000}))$(encode($param.Required))$(encode($param.PipelineInput))$(encode($param.DefaultValue))
" # Input Type $data += "

Input Type

$(encode(&{$c.inputTypes | out-string -width 2000}))" # Return Type $data += "

Return Type

$(encode(&{$c.returnValues | out-string -width 2000}))" # Notes $data += "

Notes

$(encode(&{$c.alertSet | out-string}))
" # Examples $data += "

Examples

$(encode(&{$c.Examples | out-string -width 80}))
" $data += "" $data | out-file -encoding ascii $fileName } }