Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Add a parameter to a MAML help file.
Adds a parameter to an existing, fully formatted help file.
This thing just looks for your cmdlet name, clones the first existing parameter and appends it to the bottom of the list of parameters for your cmdlet.
Add-HelpParameter -Path "C:\We've\all seen a \Filepath\before-Hlep.xml" -CmdletName New-Shiney -ParameterName "TurboShiney" -Position 1 -TyepName "String" -TypeFullName "System.String"
function Add-HelpParameter
# Path to the help file.
#Name of the cmdlet that you want to add the parameter to.
# The name of your parameter.
# The help text that describes your parameter.
# Does this parameter accept Pipeline Input?
# Is this parameter required?
# This can either be a number, or "named"
# The system type of your parameter. "String[]" for example.
# The Full Type Name of your parameter. "System.String" for eaxample.
$found = $false
[xml] $xmlDoc = get-content $Path -ErrorAction Stop
foreach ($item in ($xmlDoc.helpItems.ChildNodes).GetEnumerator())
if($ -eq $CmdletName)
$parameterClone = $item.parameters.parameter[0].Clone()
$parameterClone.required = $IsRequired.ToString().ToLower()
$parameterClone.pipelineInput = $PipelineInput.ToString().ToLower()
$parameterClone.position = $Position.ToLower()
$ = $ParameterName
$parameterClone.description.para = $HelpMessage
$parameterClone.parameterValue.'#text' = $TyepName
$ = $TypeFullName
$found = $true
if(!$found){throw "The cmdlet was not found in the specified help file."}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment