Created
February 12, 2016 12:15
-
-
Save AdamNaj/6fc02312b4a2ed714d14 to your computer and use it in GitHub Desktop.
What parameters are used by your commandlets and how many times are they defined?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$cmds = Get-Command -CommandType Cmdlet #| select -ExpandProperty Parameters #| #| ft name, count #-Property # % { $_.Keys } | Sort -Unique | |
#$cmds[733].Name | |
#$cmds[733].Parameters | gm | |
$parameters = [ordered]@{}; | |
$cmds | % { | |
if($_.Parameters.Keys.Count -gt 0){ | |
foreach($param in $_.Parameters.Keys){ | |
if($param -ne $null -and -not $parameters.Contains($param)){ | |
$parameters.Add($param, $_.Name) | |
} else { | |
$parameters[$param] = $parameters[$param] + ',' + $_.Name | |
} | |
} | |
} | |
} | |
$parameters.Keys | sort | Select @{Label="Name"; Expression={ $_ }}, @{Label="Used"; Expression={($parameters[$_] -split ',').Length+1}}, @{Label="Used By"; Expression={$parameters[$_]}} | ft -auto |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment