Recently, the Microsoft PowerShell team published a new project in preview on GitHub:
“PowerShell Private Gallery” or “PSPrivateGallery”.
The idea is quite straight forward. Providing an internal (trusted) repository which provides access to your internal resources (scripts, modules, DSC resources, etc…) using the same SDII (Software Discovery, Installation and Inventory) mechanism provided by the PackageManagement and PowerShellGet modules.
For now, the project is called the “PowerShell Private Gallery”.
You can give this preview a try by following the instructions below.
Instructions
Clone GitHub project locally (from https://github.com/PowerShell/PSPrivateGallery)
Extract the contents of the zip file into the path “C:\PSPrivateGallery”.
Expand-Archive –Path “<MydownloadFolder>\PSPrivateGallery-master.zip” –DestinationPath “C:\” –Force # Requires PSv5
Rename-Item –Path “C:\PSPrivateGallery-master\” –NewName “C:\PSPrivateGallery”
NOTE: Unblock files (remove streams) using the Unblock-File cmdlet.
dir –Path “C:\PSPrivateGallery” –Recurse | Unblock-File
Copy-Item –Path “C:\PSPrivateGallery\Modules\*” –Destination “C:\Program Files\WindowsPowerShell\Modules” –Recurse
Cd “C:\PSPrivateGallery\Configuration”
Get-Credential –Credential GalleryUser | Export-Clixml .\GalleryUserCredFile.clixml
Get-Credential –Credential GalleryAdmin | Export-Clixml .\GalleryAdminCredFile.clixml
IMPORTANT: These passwords must meet password complexity requirements for machine/domain.
- \Configuration\PSPrivateGalleryEnvironment.psd1
- \Configuration\PSPrivateGalleryPublishEnvironment.psd1
Cd “C:\PSPrivateGallery\Configuration”
.\PSPrivateGallery.ps1
Once completed, the Private PowerShell Gallery is available on http://localhost:8080.
By default, it is a clean and empty repository.
Cd “C:\PSPrivateGallery\Configuration”
.\PSPrivateGalleryPublish.ps1
Once completed, the Private PowerShell Gallery shows 3 modules imported from the Public PowerShell Gallery (PSScriptAnalyzer, ARTools and Authenticode).
Register the Private PSGallery as an internal PowerShell repository, using Register-PSRepository.
Register-PSRepository –Name PSPrivateGallery –SourceLocation “http://localhost:8080/api/v2” –InstallationPolicy Trusted –PackageManagementProvider NuGet
Get-PSRepository
Find-Module –Name PSScriptAnalyzer
Install-Module –Name PSScriptAnalyzer
Get-Module –Name PSScriptAnalyzer
Hope this helps…
Kurt Roggen [BE]
If you move unblock file to first step before extraction you won’t need to recurse the folder structure.
LikeLiked by 2 people
Great article. Simplest walk through I’ve found.
I’d like to know what your experience has been so far using this? Stable and low maintenance? Might be a better way to share internal powershell modules created but wanted your real world experience on it.
LikeLike
Posted to GitHub with a script to do it all based on your instructions. Cheers!
github[.]com/mkellerman/PSPrivateGallery
LikeLike