Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive
 

PowerShell Modules are an important resource for scripting, and the ability to share PowerShell modules is easy with online repositories like the PowerShell Gallery. The ability to publish PowerShell modules is available in  PowerShell ModuleManager v1.1.1 and later. You’re welcome!

 

Some Background on Publishing Modules

The Publish-Module command—from the PowerShellGet module—allows you to share modules from your local computer to online or local galleries.

To run the Publish-Module command, you can either specify the name or the path of the folder containing the module. If publishing by name, the first module found in the paths of the PSModulePath environment variable ($env:PSModulePath) will be published—so it is important to specify a minimum version if you have multiple versions.

 

When publishing modules to a NuGet-based online repository like the PowerShell Gallery, an API key is required. To get an API key for the PowerShell Gallery, you will need to create an account on the PowerShell Gallery and generate a new key for this module package. Local repositories do not need a key.

By default, Windows 10 ships with an old version of PowerShellGet, which provides the Publish-Module command, so this module must be updated to recognize the API key from the latest gallery site.

Publishing a module requires metadata, most of which is taken from the module manifest (.psd1). The minimum required data is:

  • Name: Unique name of module that does not already exist on the repository attempting to publish to.
  • Version: Current version of the module that must be higher than any existing versions of the module present on the repository.
  • Description: A short description of the module.
  • Author: Creator of the module.

There should be no output if the Publish-Module command runs successfully.

 

Publishing Modules just got Easier

To use the new Publish Module feature in PowerShell ModuleManager, first select the module you want to publish from the list of modules:
PMG SelectModule 1

 

Then click the Publish Module button on the ribbon (Home->Repository):
PMG ribbon publish 1

 

This will open the Publish dialog:
MMG Publish

 

Select the registered repository in the Publish to field, specify the NuGetAPI Key if you are publishing to an online repository like the PowerShell Gallery, then select the Version of the module. This is the minimum information needed to publish your module.

Optional information that can be specified when publishing:

  • Tags: Keywords used to search for modules in PowerShell repositories.
  • License Uri: The URL of licensing terms for the module.
  • Icon Uri: The URL of an icon for the module.
  • Project Uri: The URL of a website for this project.
  • Release Notes: Comments about this version of the module.

If this information already exists in the module manifest, you do not need to enter it in the Publish dialog.  Specifying this information will not automatically update the local module’s manifest. To update the local module manifest without opening and editing the psd1 file, you must check the Update the module manifest (.psd1) file checkbox:
MMG Publish check

 

After filling in the dialog, select Publish to publish the module.

 

Important Note About Repositories

Any repository you are attempting to publish to must be a registered repository in PowerShell.  Repositories can be added or edited by selecting Registered Repositories on the ribbon (Home->Repository):

PMG ribbon registeredrepo 1

Tip When registering a repository, specify where modules should be published by entering the repository URL or file path in the Publish Location field:

PMG RegisteredRepositories

Note: The default registered repository is the PowerShell Gallery (PSGallery).

A .nupkg file is created when a module is published to a registered repository, which allows you to find the published module when performing a search.

To search within repositories, open Repository Search (Home->Repository):
PMG ribbon repositorysearch 1

PMG RespositorySearch

 

Summary

If you write a PowerShell module, chances are you’ll want to publish it. Creating excellent PowerShell modules is one thing, but sharing them with others takes them to a whole new level! We hope you find this new PowerShell ModuleManager feature useful.

You will need PowerShell ModuleManager 2019 v1.1.1 or later to use the publish functionality. You can view the complete service build log here.

If you have questions about our products, please post in our support forum.
For licensed customers, use the forum associated with your product in our Product Support Forums for Registered Customers.
For users of trial versions, please post in our Trial Software Questions forum.
Copyright © 2019 SAPIEN Technologies, Inc.