Operate Your Own PowerShell Gallery

by Apr 19, 2016

With PowerShellGet, you can easily share PowerShell code. Go to www.powershellgallery.com and download the MSI installer to install PowerShellGet if you are not running the latest PowerShell 5.0 version.

In the previous tip, we showed how to search for and install modules from the PowerShell Gallery. To create your own local gallery, and share resources internally, simply create an SMB file share-based repository in your own environment. It's a one-liner!

Just make sure you set up a file share first where you have read and write permissions. Next, run this (we used \\server1\Gallery for our file share, so make sure you adjust this part):

 
PS> Register-PSRepository -Name MyTeam -SourceLocation \\server1\Gallery -InstallationPolicy Trusted

PS> Get-PSRepository

Name      PackageManagementProvider InstallationPolicy   SourceLocation                        
----      ------------------------- ------------------   --------------                        
PSGallery NuGet                     Untrusted            https://www.powershell...
MyTeam    NuGet                     Trusted              \\server1\Gallery
 

To upload content to your own gallery, use Publish-Module or Publish-Script, and specify your own internal repository.

An SMB file share-based repository is an excellent way for teams and departments to work together.

Twitter This Tip! ReTweet this Tip!