July 21st, 2013

PowerTip: Discover PowerShell Cmdlets that Accept Array of Strings

Doctor Scripto
Scripter

Summary: Learn how to find Windows PowerShell cmdlets that accept an array of strings for parameter input. Hey, Scripting Guy! Question How can I find all the Windows PowerShell cmdlets that accept an array of strings for parameter input?

Hey, Scripting Guy! Answer Import all modules, then use the Get-Command cmdlet and the ParameterName parameter to look for [string[]] (if you use aliases, the first command shortens to gmo -l | ipmo):

Get-Module –list | import-Module

Get-Command –ParameterType [string[]]

The following script counts parameter types—first it counts arrays of strings, then it counts strings (gcm is an alias for Get-Command):

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

Count    : 905

Average  :

Sum      :

Maximum  :

Minimum  :

Property :

 

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

 

Count    : 2407

Average  :

Sum      :

Maximum  :

Minimum  :

Property :

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.