PoshCode Archive  Artifact [b75c47104a]

Artifact b75c47104ad27b42a7fa8b46ba2935e8b5fb6f10c500dc8693afe1842d1f6bcf:

  • File Get-Parameter-function.ps1 — part of check-in [6507aafdbb] at 2018-06-10 12:56:20 on branch trunk — 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. (user: Oisin Grehan size: 884)

# encoding: ascii
# api: powershell
# title: Get-Parameter function
# description: 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.
# version: 0.1
# type: function
# author: Oisin Grehan
# license: CC0
# function: Get-Parameters
# x-poshcode-id: 1053
# x-archived: 2016-03-05T10:54:42
# x-published: 2010-04-22T12:32:00
#
#

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"
         }
}