| pid | 1053 |
|---|---|
| author | Oisin Grehan |
| title | Get-Parameter function |
| date | 2009-04-22 05:32:02 -0700 |
| format | posh |
| parent | 0 |
Get a dictionary of parameters for a function or cmdlet, optionally including the common parameters (verbose, debug etc) for functions using cmdletbinding, or ordinary cmdlets.
function Get-Parameters {
param([string]$CommandName, [switch]$IncludeCommon)
try {
$command = get-command $commandname
$parameters = (new-object System.Management.Automation.CommandMetaData $command, $includecommon).Parameters
$parameters.getenumerator() # unroll dictionary
} catch {
write-warning "Could not find command or obtain parameters for $commandname"
}
}