Tips and Tricks

Tips and Tricks

Create coding guidelines

Prevent re-inventing the wheel - except your wheel besser ;-)

Tips and Tricks

Pre-install required modules for Update-ModuleManifest to work

Add build number to ModuleVersion in module manifest

Update-ModuleManifest mangles nicely formatted module manifest

Test against the module instead of the *.ps1 files

Ways to load a module

Load from well-known location


Load from arbitrary location

Import-Module -Name .\MyModule\MyModule.psd1

Loading from location of source files

$Env:PSModulePath = "~\MyModules;$Env:PSModulePath"

Private module repository

Some code must remain private

Use any NuGet feed to host modules

Supported in many commercial products

Create your own feed using NuGet.Server from .NET Foundation

Prerelease versions

Module manifest can contain a prerelease tag :

  ModuleVersion = '2.0.0'
  PrivateData = @{
    PSData = @{
      Prerelease = '-alpha'

This can be used when working with modules:

Find-Module -Name GoCD -AllowPrerelease
Install-Module -Name GoCD -AllowPrerelease

Prerelease versions

ModuleVersion usually follows SemVer

ModuleVersion may be MAJOR.MINOR.PATCH.BUILD

RequiredModules must follow SemVer like MAJOR.MINOR.PATCH

RequiredModules does not allow prerelease tag

Try to avoid prerelease tags