“PowerShell Private Gallery” – Your internal PowerShell Repository


Recently, the Microsoft PowerShell team published a new project in preview on GitHub:
“PowerShell Private Gallery” or “PSPrivateGallery”.

image33_thumb

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”.

image

You can give this preview a try by following the instructions below.

Instructions

  • Clone GitHub project locally (from https://github.com/PowerShell/PSPrivateGallery)

    image

  • 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 PSGallery DSC Resources to the $env:PSModulePath – Copy Modules folder contents to $env:ProgramFiles\WindowsPowerShell\Modules

    Copy-Item –Path “C:\PSPrivateGallery\Modules\*” –Destination “C:\Program Files\WindowsPowerShell\Modules” –Recurse

  • Generate Credential files for both user and admin

    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.

  • Update Configuration Data to your needs (Optional)
    • \Configuration\PSPrivateGalleryEnvironment.psd1
    • \Configuration\PSPrivateGalleryPublishEnvironment.psd1
  • Deploy the PowerShell Gallery, using PSPrivateGallery.ps1

    Cd “C:\PSPrivateGallery\Configuration”
    .\PSPrivateGallery.ps1

    image

  • Once completed, the Private PowerShell Gallery is available on http://localhost:8080.

    image

  • By default, it is a clean and empty repository.

    image

  • Populate the local instance of the Gallery with specified PowerShell modules, using PSPrivateGalleryPublish.ps1.

    Cd “C:\PSPrivateGallery\Configuration”
    .\PSPrivateGalleryPublish.ps1

    image

  • Once completed, the Private PowerShell Gallery shows 3 modules imported from the Public PowerShell Gallery (PSScriptAnalyzer, ARTools and Authenticode).

    image

  • 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

    image

  • Verify the PowerShell repository as internal source, using Get-PSRepository.

    Get-PSRepository

    image

  • Discovery, Installation and Inventory of module using the internal/private PowerShell repository

    Find-Module –Name PSScriptAnalyzer
    Install-Module –Name PSScriptAnalyzer
    Get-Module –Name PSScriptAnalyzer

    image

    Hope this helps…

    Kurt Roggen [BE]

  • Advertisements

    One thought on ““PowerShell Private Gallery” – Your internal PowerShell Repository

    Leave a Reply

    Fill in your details below or click an icon to log in:

    WordPress.com Logo

    You are commenting using your WordPress.com account. Log Out / Change )

    Twitter picture

    You are commenting using your Twitter account. Log Out / Change )

    Facebook photo

    You are commenting using your Facebook account. Log Out / Change )

    Google+ photo

    You are commenting using your Google+ account. Log Out / Change )

    Connecting to %s