February 21st, 2013

PowerTip: Count the Number of Commands Exposed by Imported Modules

Doctor Scripto
Scripter

Summary: Learn how to count the number of commands exposed by imported Windows PowerShell modules.

Hey, Scripting Guy! Question I want to know how many commands are available through the modules I have imported into my current Windows PowerShell session. How can I do this?

Hey, Scripting Guy! Answer Use the Get-Module cmdlet and pipe the results to the Foreach-Object cmdlet (% is an alias). Inside the script block, use the Get-Command cmdlet to return the commands from each module. Send the results to the Measure-Object (measure is an alias) cmdlet, as shown here.

Get-Module | % {Get-Command -Module $_.name} | measure

 

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.