Edit

Share via


Getting Started with the PowerShell Gallery

The PowerShell Gallery is a package repository containing scripts, modules, and DSC resources you can download and use. 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.

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.

After you select a package, you may want to learn more about it. Examine the package page on the Gallery. The package page includes the metadata uploaded with the package. The metadata is provided by the author of the package. Microsoft doesn't verify this information. The Owner of the package is associated with the Gallery account used to publish the package. The Owner account is more authoritative than the Author field.

If you discover a package that you feel isn't published in good faith, select 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

We encourage the following process when downloading packages from the PowerShell Gallery:

Inspect

To download a package from the Gallery for inspection, use the Save-Module or Save-Script cmdlets on the package. These commands save the package locally without installing it. Inspect the package contents. Remember to delete the saved package manually.

Some 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, select 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.

By default, Install-Module installs the module to $env:ProgramFiles\WindowsPowerShell\Modules location by default, which requires an administrator account. If you add the -Scope CurrentUser parameter, the command installs the module in $HOME\Documents\WindowsPowerShell\Modules .

By default, Install-Script installs the script to $env:ProgramFiles\WindowsPowerShell\Scripts location, which requires an administrator account. If you add the -Scope CurrentUser parameter, the command installs the script in $HOME\Documents\WindowsPowerShell\Scripts.

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, select Azure Automation, then select Deploy to Azure Automation on the package details page. You're redirected to the Azure Management Portal where you sign in using your Azure account credentials. 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.

To update packages installed from the PowerShell Gallery, run either the Update-Module or Update-Script cmdlet. When run without any other 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 other parameters, Update-Script also attempts to update all scripts installed by running Install-Script. To selectively update scripts, add the -Name parameter.

To find out which modules you 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 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.

Important

The PowerShell Gallery requires Transport Layer Security (TLS) 1.2 or higher. 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

These hostnames should be added to the allow lists that control access from your network.

Hosts required for package discovery and download:

  • cdn.oneget.org
  • cdn.powershellgallery.com

Hosts required when using the PowerShell Gallery website:

  • *.powershellgallery.com - website
  • go.microsoft.com and aka.ms - redirection services

Note

The old endpoints that ended with azureedge.net are no longer supported.