Get-Module Manifest Metadata

HvyOnEz SolidGround 0 Reputation points
2023-03-15T16:53:15.9366667+00:00

I've created a module with manifest in order to export two of the three contained functions. The function works as expected but the "ExportedCommands" metadata via the Get-Module -Name Get-ServerInventory is missing.

When I test the manifest via Test-ModuleManifest (Get-Module Get-ServerInventory).Path

The "ExportedCommands" metadata is visible.

Why do I not see the "ExportedCommands" metadata via the Get-Module -Name Get-ServerInventory command?

P.S. The Export-ModuleMember -Function Get-InventoryCMD, Get-Inventory is also within the PSM1 file

Missing "ExportedCommnds"

User's image

PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,595 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. HvyOnEz SolidGround 0 Reputation points
    2023-03-15T17:44:03.81+00:00

    I think that I found an answer:
    Get-Module will ONLY return the "ExportedCommands" metadata for a Script Module (PSM1) File when the module does not have an associated Manifest (PSD1) File

    If you use a Manifest and you want the "ExportedCommands" , you must:

    1. Comment-Out the "RootModule" from the Manifest File
    2. Nest the Get-Module command within the Test-Manifest command so that the file returned is a (PSD1) file
      Test-ModuleManifest (Get-Module -Name Get-ServerInventory).Path

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.