How do I retrieve the available commands from a module?

PowershellModulePowershell 2.0

Powershell Problem Overview


To know which PowerShell modules are available on a machine I use the command

Get-Module -ListAvailable

This returns a list with module-type, -name and the exported commands. But the exported commands are always empty and just displaying {}. Why is this not displayed?

Do I have to use another parameter or is there another cmdlet or method to retrieve the available commands?

Powershell Solutions


Solution 1 - Powershell

Exported commands are not available if the module is not loaded. You need to load the module first and then execute Get-Command:

Import-Module -Name <ModuleName>
Get-Command -Module <ModuleName>

Solution 2 - Powershell

Use the parameter -ListAvailable

Get-Module <moduleName> -ListAvailable | % { $_.ExportedCommands.Values }

"<moduleName>" is optional. Omit to show all available modules.

Solution 3 - Powershell

This will List all the commands under a module and search through them:

Get-Command -Module dbatools| ?{$_.name -match 'service'}

Solution 4 - Powershell

[enter image description here][1]In the meantime this command here answers the question:

Get-Command -Module <#Your Module#>

Pretty simple...

Here the Output: https://imgur.com/a/DMWeuKP

Solution 5 - Powershell

PowerShell 2.0 - this works for me:
Get-Module <moduleName> | % {$_.ExportedCommands.Values}
To list the loaded modules in the current session:
Get-Module

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionTomView Question on Stackoverflow
Solution 1 - PowershellShay LevyView Answer on Stackoverflow
Solution 2 - Powershelluser2095160View Answer on Stackoverflow
Solution 3 - PowershellSAKA UKView Answer on Stackoverflow
Solution 4 - PowershellBartek KahlView Answer on Stackoverflow
Solution 5 - Powershelluser1390375View Answer on Stackoverflow