Trevor Sullivan's Tech Room

Minding the gap between administration and development

PowerShell: Determine Number of Parameters on Cmdlets

Posted by Trevor Sullivan on 2011/08/17

In PowerShell, each “cmdlet” has input and output parameters. Cmdlet definitions (including their names, parameters, parameters sets, attributes, etc.) are rich objects, just like every other object in PowerShell. Because of this, we can easily find out which cmdlets have the most parameters.

We follow this process to retrieve the information mentioned above:

  1. Retrieve a list of cmdlets available in the current PowerShell session
  2. Select the Name and parameter count (the latter, using a “calculated property” expression)
  3. Sort the results descending by parameter count

Get-Command -CommandType cmdlet | Select-Object -Property Name,@{Name = 'Parameter Count';Expression = {[int]$_.Parameters.Count} } | sort 'Parameter Count' –Descending

Here is what the results look like:

Name                                                                                                    Parameter Count
—-                                                                                                    —————
New-ModuleManifest                                                                                                   38
New-PSSessionOption                                                                                                  28
Invoke-Command                                                                                                       28
Get-WSManInstance                                                                                                    28
Get-WmiObject                                                                                                        26
Set-WmiInstance                                                                                                      25
Invoke-WmiMethod                                                                                                     25
Set-WSManInstance                                                                                                    24
Register-PSSessionConfiguration                                                                                      24
Remove-WmiObject                                                                                                     23
Enter-PSSession                                                                                                      23
Import-Module                                                                                                        23
Add-Type                                                                                                             23
Invoke-WSManAction                                                                                                   23
Set-PSSessionConfiguration                                                                                           23
Copy-Item                                                                                                            22
Set-ItemProperty                                                                                                     22
New-WSManInstance                                                                                                    22
Start-Process                                                                                                        22
Get-EventLog                                                                                                         22
New-PSSession                                                                                                        22
Send-MailMessage                                                                                                     22
Rename-ItemProperty                                                                                                  21
Get-Content                                                                                                          21


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: