Member-only story

How to Sign Your PowerShell Modules with PSResourceGet’s New Cmdlet

Gijs Reijn
4 min readSep 9, 2024

--

Many best practices are available to prepare your module to be published in the PowerShell Gallery. From using PSScriptAnalyzer rules, and providing documentation with examples, to signing your code.

While code signing has been around for a long time, the Microsoft.PowerShell.PSResourceGet one that replaces the PowerShellGet module is not. Now you might wonder, why are you telling me this?

The Microsoft.PowerShell.PSResourceGet module provides new cmdlets responsible for publishing your module to the gallery. You might already have guessed it — the Publish-PSResource cmdlet is the one that does the heavy lifting.

Using Publish-PSResource cmdlet did not allow you to sign the relevant .nupkg file because if you are using the -Repository parameter and used the PSGallery as a source, it would instantly push the package to the gallery.

Technically, you can save the .nupkg file first, sign it, and push it again using the -DestinationPath parameter

In this tutorial, you are going to learn how to package your module using a new cmdlet, then sign the package, and additionally publish the resource. Additionally, you will:

  • Build the PSResourceGet repository
  • Generate self-signed certificate

--

--

Gijs Reijn
Gijs Reijn

Written by Gijs Reijn

Sharing my experience through the IT world. Tutorials, guides, and opinions. Follow my newsletter at: http://eepurl.com/i1hSUw

No responses yet