New-ModuleManifest | Taking on PowerShell one cmdlet at a time | Weekly Blog

Share this post:

This is a part of an on-going blog series written by Adam Gordon. Each week, Adam will walk you through a PowerShell command, showing you when and how to use each one. This week, Adam covers New-ModuleManifest.

When to use New-ModuleManifest?

The New-ModuleManifest cmdlet creates a new module manifest (.psd1) file, populates its values, and saves the manifest file in the specified path.

Module authors can use this cmdlet to create a manifest for their module. A module manifest is a .psd1 file that contains a hash table. The keys and values in the hash table describe the contents and attributes of the module, define the prerequisites, and determine how the components are processed. Manifests are not required for a module.

New-ModuleManifest creates a manifest that includes all the commonly used manifest keys, so you can use the default output as a manifest template. To add or change values, or to add module keys that this cmdlet does not add, open the resulting file in a text editor.

Each parameter, except for –Path and –PassThru, creates a module manifest key and its value. In a module manifest, only the ModuleVersion key is required. Unless specified in the parameter description, if you omit a parameter from the command, New-ModuleManifest creates a comment string for the associated value that has no effect.

In PowerShell 2.0, New-ModuleManifest prompts you for the values of commonly used parameters that are not specified in the command, in addition to required parameter values. Beginning in PowerShell 3.0, New-ModuleManifest prompts only when required parameter values are not specified.

If you are planning to publish your module in the PowerShell Gallery, the manifest must contain values for certain properties.

What version of PowerShell am I using?

Get the PowerShell Version from your machine:


This command shows you the PowerShell version information on your machine.

How to use New-ModuleManifest?

Create a new module manifest:

New-ModuleManifest -Path C:\PShellTest\Test-Module.psd1 -PassThru

This example creates a new module manifest in the file that is specified by the –Path parameter. The –PassThru parameter sends the output to the pipeline and to the file.

The output shows the default values of all keys in the manifest.

Create a new manifest with some prepopulated settings:

New-ModuleManifest -PowerShellVersion 1.0 -AliasesToExport JKBC, DRC, TAC -Path C:\PShellTest\ManifestTest.psd1

This example creates a new module manifest. It uses the –PowerShellVersion and –AliasesToExport parameters to add values to the corresponding manifest keys.

Create a manifest that requires other modules:

$moduleSettings = @{
RequiredModules = (“BitsTransfer”, @{
Path = ‘C:\PShellTest\ManifestTest2.psd1’

New-ModuleManifest @moduleSettings

This example uses a string format to specify the name of the BitsTransfer module and the hash table format to specify the name, a GUID, and a version of the PSScheduledJob module.

This example shows how to use the string and hash table formats of the –ModuleList, –RequiredModules, and –NestedModules parameter. You can combine strings and hash tables in the same parameter value.

Create a manifest that supports updateable help:

$moduleSettings = @{/span>
HelpInfoUri = ‘http://’
Path = ‘C:\PShellTest\ManifestTest3.psd1’

New-ModuleManifest @moduleSettings


This example uses the –HelpInfoUri parameter to create a HelpInfoUri key in the module manifest. The value of the parameter and the key must begin with http or https. This value tells the Updatable Help system where to find the HelpInfo XML updatable help information file for the module.

Getting module information:

Get-Module Microsoft.PowerShell.Diagnostics -List | Format-List -Property *

This example shows how to get the configuration values of a module. The values in the module manifest are reflected in the values of properties of the module object.

The Get-Module cmdlet is used to get the Microsoft.PowerShell.Diagnostics module using the –List parameter. The command sends the module to the Format-List cmdlet to display all properties and values of the module object.

Learn last week’s command: New-Module.

Need PowerShell training? Check out ITProTV’s PowerShell online IT training courses.