Getting Started with the PowerShell Gallery
The PowerShell Gallery is a package repository containing scripts, modules, and DSC resources you can download and leverage. You use the cmdlets in the PowerShellGet module to install packages from the PowerShell Gallery. You don't need to sign in to download items from the PowerShell Gallery.
Note
It's possible to download a package from the PowerShell Gallery directly, but this isn't a recommended approach. For more details, see Manual Package Download.
Discovering packages from the PowerShell Gallery
You can find packages in the PowerShell Gallery using the Search control on the PowerShell
Gallery's home page, or by browsing through the Modules and Scripts from the
Packages page. You can also find packages from the PowerShell Gallery by running the
Find-Module
, Find-DscResource
, and Find-Script
cmdlets, depending on the package type, with
-Repository PSGallery
.
You can filter results from the Gallery using the following parameters:
- Name
- AllVersions
- MinimumVersion
- RequiredVersion
- Tag
- Includes
- DscResource
- RoleCapability
- Command
- Filter
If you're only interested in discovering specific DSC resources in the Gallery, you can run the
Find-DscResource
cmdlet. Find-DscResource returns data on DSC resources contained in the Gallery.
Because DSC resources are always delivered as part of a module, you still need to run
Install-Module
to install those DSC resources.
Learning about packages in the PowerShell Gallery
Once you've identified a package that you're interested in, you may want to learn more about it. You can do this by examining that package's specific page on the Gallery. On that page, you'll be able to see all the metadata uploaded with the package. This metadata is provided by the package's author, and is not verified by Microsoft. The Owner of the package is strongly tied to the Gallery account used to publish the package, and is more trustworthy than the Author field.
If you discover a package that you feel isn't published in good faith, click Report Abuse on that package's page.
If you're running Find-Module
or Find-Script
, you can view this data in the returned
PSGetModuleInfo object. The following example returns data on the PSReadLine module in the
Gallery.
Find-Module -Name PSReadLine -Repository PSGallery | Get-Member
Downloading packages from the PowerShell Gallery
We encourage the following process when downloading packages from the PowerShell Gallery:
Inspect
To download a package from the Gallery for inspection, run either the Save-Module
or Save-Script
cmdlet, depending on the package type. This lets you save the package locally without installing it,
and inspect the package contents. Remember to delete the saved package manually.
Some of these packages are authored by Microsoft, and others are authored by the PowerShell community. Microsoft recommends that you review the contents and code of packages on this gallery before installation.
If you discover a package that you feel isn't published in good faith, click Report Abuse on that package's page.
Install
To install a package from the Gallery for use, run either the Install-Module
or Install-Script
cmdlet, depending on the package type.
Install-Module
installs the module to $env:ProgramFiles\WindowsPowerShell\Modules
by default.
This requires an administrator account. If you add the -Scope CurrentUser
parameter, the module is
installed to $HOME\Documents\WindowsPowerShell\Modules
.
Install-Script
installs the script to $env:ProgramFiles\WindowsPowerShell\Scripts
by default.
This requires an administrator account. If you add the -Scope CurrentUser
parameter, the script is
installed to $HOME\Documents\WindowsPowerShell\Scripts
.
By default, Install-Module
and Install-Script
installs the most
current version of a package. To install an older version of the package, add the -RequiredVersion
parameter.
Deploy
To deploy a package from the PowerShell Gallery to Azure Automation, click Azure Automation, then click Deploy to Azure Automation on the package details page. You are redirected to the Azure Management Portal where you sign in using your Azure account credentials. Note that deploying packages with dependencies deploys all the dependencies to Azure Automation. The 'Deploy to Azure Automation' button can be disabled by adding the AzureAutomationNotSupported tag to your package metadata.
To learn more about Azure Automation, see the Azure Automation documentation.
Updating packages from the PowerShell Gallery
To update packages installed from the PowerShell Gallery, run either the Update-Module
or
Update-Script
cmdlet. When run without any additional parameters, Update-Module
attempts to
update all modules installed by running Install-Module
. To selectively update modules, add the
-Name
parameter.
Similarly, when run without any additional parameters, Update-Script
also attempts to update all
scripts installed by running Install-Script
. To selectively update scripts, add the -Name
parameter.
List packages that you have installed from the PowerShell Gallery
To find out which modules you have installed from the PowerShell Gallery, run the
Get-InstalledModule
cmdlet. This command lists all the modules you have on your system that were
installed directly from the PowerShell Gallery.
Similarly, to find out which scripts you have installed from the PowerShell Gallery, run the
Get-InstalledScript
cmdlet. This command lists all the scripts you have on your system that were
installed directly from the PowerShell Gallery.
Network access to the PowerShell Gallery
These hostnames should be added to the allow lists that control access from your network.
Hosts required for package discovery and download:
onegetcdn.azureedge.net
- CDN hostname used by the PowerShellGet modulepowershellgallery.azureedge.net
- CDN hostname used by the PowerShellGet and Microsoft.PowerShell.PSResourceGet modules
Hosts required when using the PowerShell Gallery website:
*.powershellgallery.com
- websitego.microsoft.com
- redirection service
Important
As of April 2020, the PowerShell Gallery no longer supports Transport Layer Security (TLS) versions 1.0 and 1.1. If you are not using TLS 1.2 or higher, you will receive an error when trying to access the PowerShell Gallery. Use the following command to ensure you are using TLS 1.2:
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
For more information, see the announcement in the PowerShell blog.
Related links
PowerShellGet & Gallery