PoshCode Archive  Artifact [8521a6976b]

Artifact 8521a6976bae799f0ac606ac4beb4efa087a14846e1ca3d987ed194a90f2250c:

  • File Get-Parameter.ps1 — part of check-in [3e10580577] at 2018-06-10 13:12:10 on branch trunk — Give as input a cmdlet name. Output is a set of properties about each parameter, including: name, parameter set, aliases, ismandatory, and CommonParameter. Thanks to LucD for the technique. (user: halr9000 size: 1162)

# encoding: ascii
# api: powershell
# title: Get-Parameter
# description: Give as input a cmdlet name.  Output is a set of properties about each parameter, including: name, parameter set, aliases, ismandatory, and CommonParameter.  Thanks to LucD for the technique.
# version: 0.1
# type: function
# author: halr9000
# license: CC0
# function: Get-Parameter
# x-poshcode-id: 255
# x-archived: 2009-11-14T08:22:37
#
#
function Get-Parameter ($Cmdlet) {
	foreach ($paramset in (Get-Command $Cmdlet).ParameterSets){
		$Output = @()
		foreach ($param in $paramset.Parameters) {
			$process = "" | Select-Object Name, ParameterSet, Aliases, IsMandatory, CommonParameter
			$process.Name = $param.Name
			if ( $paramset.name -eq "__AllParameterSets" ) { $process.ParameterSet = "Default" }
			else { $process.ParameterSet = $paramset.Name }
			$process.Aliases = $param.aliases
			$process.IsMandatory = $param.IsMandatory 
			if ($param.aliases -match "vb|db|ea|wa|ev|wv|ov|ob") { $process.CommonParameter = $TRUE }
			else { $process.CommonParameter = $FALSE }
			$output += $process
		}
		Write-Output $Output
		#Write-Host "`n"
	}
}