PowerTip: Count the Number of Commands Exposed by Imported Modules

Doctor Scripto

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



Discussion is closed.

Feedback usabilla icon