Page 1 of 1

Replicate Parameter text in a Help file

Posted: Wed Dec 30, 2015 3:49 pm
While writing Help for a module, the same parameter was used on multiple cmdlets.
Instead of manually replicating the text, I wrote the following short script that does that for you.

The colour code I used on the parameters:
  • Green - parameter Help present
  • Yellow - parameter Help copied
  • Red - no parameter Help found
Verify the generated XML before overwriting or replacing the old file!

Code: Select all

# Scans all cmdlets and parameters in a Help file
# Stores the parameter Help text, if it finds any
# Fills in the Help text on parameters with the same name that have no Help text
# Result is saved in HelpFile-new.xml

$HelpFile = 'HelpFile.xml'

[xml]$help = Get-Content -Path $HelpFile

$parmTab = @{}

# Requires 2 runs to be independent of the order in the XML file
1..2 | %{
Write-Host -ForegroundColor Blue "`nRun $_`n"
# For each cmdlet
foreach($cmd in $help.helpItems.command){
Write-Host "$($"
# For each parameter
foreach($parm in $cmd.parameters.parameter){
# Do we have help for that parameter
Write-Host -ForegroundColor Green -NoNewline "`t$($"
# Remember it
Write-Host -ForegroundColor Green "`t`t$($parm.description.para)"
# Did we already have a text for this parameter
Write-Host -ForegroundColor Yellow -NoNewline "`t$($`t`t$($parmTab.Item($"
# Enter the help text
$parm.description.para = $parmTab.Item($
Write-Host -ForegroundColor Red -NoNewline "`t$($"
Write-Host ''


Re: Replicate Parameter text in a Help file

Posted: Wed Dec 30, 2015 4:39 pm
by juneblender
Awesome. Thanks so much.