# encoding: ascii
# api: powershell
# title: Get-Parameter
# description: <dl><dt>Description</dt>
# version: 0.1
# type: function
# author: halr9000
# license: CC0
# function: Get-Parameter
# x-poshcode-id: 440
# x-derived-from-id: 441
# x-archived: 2009-11-13T21:31:12
#
# <dd>Get-Parameter is used to obtain all of the parameters for a cmdlet. It also returns info like aliases and whether a parameter is mandatory.</dd>
# <dt>Usage:</dt>
# <dd><code>Get-Parameter <Cmdlet Name> | ft -GroupBy ParameterSet</code></dd>
# <dt>Revisions:</dt>
# <dd>0.8
# <ul>
# <li>Does not show common params by default, added switch to override.</li>
# <li>Added Position property</li>
# </ul>
# </dd>
# </dl>
#
function Get-Parameter ( $Cmdlet, [switch]$ShowCommon ) {
foreach ($paramset in (Get-Command $Cmdlet).ParameterSets){
$Output = @()
foreach ($param in $paramset.Parameters) {
if ( !$ShowCommon ) {
if ($param.aliases -match "vb|db|ea|wa|ev|wv|ov|ob") { continue }
}
$process = "" | Select-Object Name, ParameterSet, Aliases, Position, IsMandatory
$process.Name = $param.Name
if ( $paramset.name -eq "__AllParameterSets" ) { $process.ParameterSet = "Default" }
else { $process.ParameterSet = $paramset.Name }
$process.Aliases = $param.aliases
if ( $param.Position -lt 0 ) { $process.Position = $null }
else { $process.Position = $param.Position }
$process.IsMandatory = $param.IsMandatory
$output += $process
}
Write-Output $Output
}
}