Publish a PowerShell Module to MyGet

With PowerShell 5.0 and the latest PowerShellGet, private feeds on MyGet can be used to store private PowerShell Modules. The following script demonstrates how to push a PowerShell Module to a MyGet feed.

Import-Module PowerShellGet
$PSGalleryPublishUri = '<feed-name-goes-here>/api/v2/package'
$PSGallerySourceUri = '<feed-name-goes-here>/api/v2'
$APIKey = '<api-key-for-MyGet-goes-here>'

Register-PSRepository -Name MyGetFeed -SourceLocation $PSGallerySourceUri -PublishLocation $PSGalleryPublishUri
Publish-Module -Path <path-to-module> -NuGetApiKey $APIKey -Repository MyGetFeed -Verbose

The Register-PSRepository registers the MyGet feed as a PowerShellGet repository. The Publish-Module publishes the module to the previously registered PowerShellGet module.

PowerShellGet also has the -Credential parameter which can be used with private feeds.

Note: If you want to update the PowerShellGet repository, use the Set-PSRepository CmdLet.

Found an issue with the documentation on this page? We accept contributions!
Read our contribution guidance or edit this page's source on GitHub.