PowerTip: Discover which PowerShell Cmdlets Have Parameter to Accept Specific Type

Doctor Scripto

Summary: Learn how to find Windows PowerShell cmdlets that have a specific parameter that accepts specific types.

Hey, Scripting Guy! Question How can I find all Windows PowerShell cmdlets that have a parameter named ComputerName that accepts an array of strings?

Hey, Scripting Guy! Answer Import all the modules, then use the Get-Command cmdlet to look for a ParameterName of ComputerName and a ParameterType of [string[]]:

Get-Module –list | import-Module

Get-Command –ParameterType [string[]] –ParameterName ComputerName

The following script counts how many cmdlets have a parameter named ComputerName that accepts a string, and how many accept an array of strings:

PS C:> gcm -ParameterType [string] -ParameterName computername | measure

 

Count    : 549

Average  :

Sum      :

Maximum  :

Minimum  :

Property :

 

PS C:> gcm -ParameterType [string[]] -ParameterName computername | measure

 

Count    : 204

Average  :

Sum      :

Maximum  :

Minimum  :

Property :

0 comments

Discussion is closed.

Feedback usabilla icon