Learning and Sharing
  • Home
  • Blog
  • Linux
  • macOS
  • Virtualization
    • VMware
    • VirtualBox
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
  • Home
  • Blog
  • Linux
  • macOS
  • Virtualization
    • VMware
    • VirtualBox
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
No Result
View All Result

How to Count the Number of Commands of an Installed PowerShell Module

May 24, 2024
in Blog, Powershell
0
ADVERTISEMENT

Table of Contents

Count the number of commands of an installed module

In some cases, you want to know how many commands are available through a PowerShell module that you’ve installed in your computer.

1. Get the list of the installed PowerShell modules.

Get-InstalledModule
Version Name                       Repository
------- ----                       ----------
11.6.0  Az                         PSGallery
2.19.0  Az.Accounts                PSGallery
2.0.1   Az.Advisor                 PSGallery
6.0.3   Az.Aks                     PSGallery
1.1.4   Az.AnalysisServices        PSGallery
4.0.2   Az.ApiManagement           PSGallery
1.0.0   Az.App                     PSGallery
...

2. Get the list commands of a single PowerShell module.

Get-Command -Module 'MicrosoftTeams'
CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Cmdlet          Add-TeamChannelUser                                6.2.0      MicrosoftTeams
Cmdlet          Add-TeamUser                                       6.2.0      MicrosoftTeams
Cmdlet          Clear-TeamsEnvironmentConfig                       6.2.0      MicrosoftTeams
Cmdlet          Connect-MicrosoftTeams                             6.2.0      MicrosoftTeams
Cmdlet          Disconnect-MicrosoftTeams                          6.2.0      MicrosoftTeams
Cmdlet          Get-AllM365TeamsApps                               6.2.0      MicrosoftTeams
Cmdlet          Get-AssociatedTeam                                 6.2.0      MicrosoftTeams
...

3. Count the number of commands.

Get-Command -Module 'MicrosoftTeams' | measure | select Count
Count
-----
  556

4. Run the following command to count the number of commands of modules using a wildcard. For example, count the number of commands of the Azure PowerShell modules.

(Get-Command -Module "az*").Count
PS C:\> (Get-Command -Module "az*").Count
5796
PS C:\> (Get-Command -Module "*Microsoft.Graph.*").Count
8938

5. In case you want to build a report for all PowerShell modules. Use the below code snippet:

$array = @()
foreach ($module in Get-InstalledModule) {
        $a = (Get-Command -Module $($module.Name) | measure).Count
        $object = New-Object -TypeName PSObject -Property $([ordered]@{
            Name    = $module.Name
            Verison = $module.Version
            Count   = $a
        })
          $array += $object
    }
$array | Sort-Object -Property Count -Descending
Name                     Verison    Count
----                     -------    -----
Microsoft.Graph.Intune   6.1907.1.0  1569
MicrosoftTeams           6.2.0        556
AzureAD                  2.0.2.182    231
MSOnline                 1.1.183.81    96
ExchangeOnlineManagement 3.5.0         33
PowerShellGet            2.2.5         26
PSMDATP                  1.1.0         24
UniversalPrintManagement 1.13.0        16
PackageManagement        1.4.8.1       13

Count the number of commands in current session

For the current PowerShell session, the below command will list all imported modules:

Get-Module | select Name, Version
Name                                            Version
----                                            -------
Microsoft.Graph.Applications                    2.19.0
Microsoft.Graph.Authentication                  2.19.0
Microsoft.Graph.Bookings                        2.19.0
Microsoft.Graph.DeviceManagement.Actions        2.19.0
Microsoft.Graph.DeviceManagement.Administration 2.19.0
Microsoft.Graph.DeviceManagement.Enrollment     2.19.0
...

Count the total commands are available through the modules that have imported into the current Windows PowerShell session.

Get-Module | foreach {Get-Command -Module $_.Name} | measure | select Count
Count
-----
 7493

In case you want to get the details about each module. Use the Get-Module cmdlet and pipe the results to the Foreach loop. 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.

$array = @()
foreach ($module in Get-Module) {
        $a = (Get-Command -Module $($module.Name) | measure).Count
        $object = New-Object -TypeName PSObject -Property $([ordered]@{
            Name    = $module.Name
            Verison = $module.Version
            Count   = $a
        })
          $array += $object
    }
$array | Sort-Object -Property Count -Descending
Name                                            Verison Count
----                                            ------- -----
Microsoft.Graph.Devices.CorporateManagement     2.19.0   1133
Microsoft.Graph.Files                           2.19.0   1076
Microsoft.Graph.Sites                           2.19.0   1018
Microsoft.Graph.Teams                           2.19.0    654
MicrosoftTeams                                  6.2.0     556
Microsoft.Graph.Identity.DirectoryManagement    2.19.0    354
Microsoft.Graph.Groups                          2.19.0    350
...
ADVERTISEMENT

Not a reader? Watch this related video tutorial:

Rate this post
Previous Post

What’s the Difference Between Deallocated and Stopped of Azure VMs

Next Post

How to Set the Default Location in Azure PowerShell

Related Posts

Running Hyper-V and VMware Workstation on The Same Machine

August 15, 2024

How to Uninstall All Autodesk Products At Once Silently

July 29, 2024
Ftr5

How to Uninstall the Autodesk Genuine Service on Windows

July 29, 2024
Ftr19

How to Fix Windows Cannot Read the ProductKey From the Unattend Answer File in VirtualBox

July 26, 2024
Ftr25

How to Update Windows Terminal in Windows 10/11

July 26, 2024

How to Disable The Beep Sound in WSL Terminal on Windows

July 26, 2024

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • How To Turn On uBlock Origin Extension in Chrome (2025)
  • Images Hidden Due To Mature Content Settings In CivitAI
  • Azure OpenAI vs Azure AI Hub, How to Choose the Right One for Your Needs

Categories

Stay in Touch

Discord Server

Join the Discord server with the site members for all questions and discussions.

Telegram Community

Jump in Telegram server. Ask questions and discuss everything with the site members.

Youtube Channel

Watch more videos, learning and sharing with Leo ❤❤❤. Sharing to be better.

Newsletter

Join the movement and receive our weekly Tech related newsletter. It’s Free.

General

Microsoft Windows

Microsoft Office

VMware

VirtualBox

Technology

PowerShell

Microsoft 365

Microsoft Teams

Email Servers

Copyright 2025 © All rights Reserved. Design by Leo with ❤

No Result
View All Result
  • Home
  • Linux
  • Intune
  • macOS
  • VMware
  • VirtualBox
  • Powershell
  • Windows 10
  • Windows 11
  • Microsoft 365
  • Microsoft Azure
  • Microsoft Office
  • Active Directory

No Result
View All Result
  • Home
  • Linux
  • Intune
  • macOS
  • VMware
  • VirtualBox
  • Powershell
  • Windows 10
  • Windows 11
  • Microsoft 365
  • Microsoft Azure
  • Microsoft Office
  • Active Directory