get-parameter.ps1

前端之家收集整理的这篇文章主要介绍了get-parameter.ps1前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
http://halr9000.com/article/507
 
param ( 
  $Cmdlet,[switch]$ShowCommon,[switch]$Full
)

$command = Get-Command $Cmdlet -ea silentlycontinue 

# resolve aliases (an alias can point to another alias)
while ($command.CommandType -eq "Alias") {
	$command = Get-Command ($command.definition)
}
if (-not $command) { return }

foreach ($paramset in $command.ParameterSets){
	$Output = @()
	foreach ($param in $paramset.Parameters) {
		if ( ! $ShowCommon ) {
			if ($param.aliases -match "vb|db|ea|wa|ev|wv|ov|ob|wi|cf") { continue }
		}
		$process = "" | Select-Object Name,Type,ParameterSet,Aliases,Position,IsMandatory,Pipeline,PipelineByPropertyName
		$process.Name = $param.Name
		if ( $param.ParameterType.Name -eq "SwitchParameter" ) {
			$process.Type = "Boolean"
		}
		else {
			switch -regex ( $param.ParameterType ) {
				"Nullable``1\[(.+)\]" { $process.Type = $matches[1].Split('.')[-1] + " (nullable)" ; break }
				default { $process.Type = $param.ParameterType.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
		$process.Pipeline = $param.ValueFromPipeline
		$process.PipelineByPropertyName = $param.ValueFromPipelineByPropertyName
		$output += $process
	}
	if ( ! $Full ) { 
		$Output | Select-Object Name,Pipeline
	}
	else { Write-Output $Output }
}
原文链接:https://www.f2er.com/vb/260718.html

猜你在找的VB相关文章