PowerShell Gallery

On this page 7

The PowerShell Gallery is the central public repository for PowerShell content, operated by Microsoft, from which administrators download and share modules, scripts and DSC resources. In Windows administration and the wider PowerShell & command line ecosystem, it plays the role that a package index plays for other languages: a single, searchable source that tools such as Install-Module and Install-PSResource query by default under the repository name PSGallery.

The Gallery matters because most modern Windows and cloud management tooling is distributed as modules rather than built into the operating system. Cloud administration modules, the Pester test framework and updated versions of PSReadLine all arrive through it, which makes the Gallery both a productivity tool and a software supply chain that deserves careful handling.

The PowerShell Gallery works as a NuGet-based package feed that client modules query over HTTPS. Each package is a compressed archive containing a module manifest or script metadata, the code files and a version number, and the client downloads, unpacks and places it in a folder listed in the $env:PSModulePath variable.

Two client modules talk to the Gallery. The older PowerShellGet module (versions 1.x and 2.x) provides cmdlets such as Find-Module, Install-Module, Update-Module and Publish-Module. Its successor, Microsoft.PowerShell.PSResourceGet, ships with PowerShell 7.4 and later, does not depend on the separate NuGet provider and uses verbs such as Find-PSResource and Install-PSResource.

The following table maps everyday tasks to the commands used in each client generation.

TaskPowerShellGet cmdletPSResourceGet cmdlet
Search for a packageFind-Module, Find-ScriptFind-PSResource
Install a packageInstall-Module, Install-ScriptInstall-PSResource
Update installed packagesUpdate-ModuleUpdate-PSResource
Download without installingSave-ModuleSave-PSResource
Publish a packagePublish-ModulePublish-PSResource
Register another repositoryRegister-PSRepositoryRegister-PSResourceRepository
Common Gallery tasks in both client modules

Package types and installation scope

The Gallery hosts several package types, and the type determines how the content is installed and used. A PowerShell module is the most common type, while standalone scripts carry their metadata in a comment-based header generated by New-ScriptFileInfo.

Package typeWhat it containsTypical use
ModuleCmdlets, functions and a .psd1 manifestReusable tooling such as cloud or directory management
ScriptA single .ps1 file with metadataOne-off automation or setup routines
DSC resourceDesired State Configuration resources inside a moduleDeclarative server configuration
Role capabilityDefinitions for Just Enough AdministrationRestricted remote administration endpoints
Content types published to the PowerShell Gallery

Installation scope decides where files land and who can use them. The CurrentUser scope writes to the profile Documents folder and needs no administrator rights, while AllUsers writes under Program Files and requires an elevated session. PowerShellGet 2.x and PSResourceGet default to CurrentUser, whereas the original PowerShellGet 1.0 in Windows PowerShell 5.1 defaulted to AllUsers, a difference that still confuses scripts written for older systems.

Windows PowerShell 5.1 and PowerShell 7 also use separate module folders, so a module installed for one edition is not automatically visible in the other unless it was placed in a shared AllUsers path.

The PowerShell Gallery distributes PowerShell code, not general desktop applications, and that is the main difference from the Windows package managers listed beside it in the same Topic. Tools such as winget, Chocolatey and Scoop install programs, while the Gallery extends the shell itself.

RepositoryWhat it distributesClientTypical install location
PowerShell GalleryModules, scripts, DSC resourcesPowerShellGet or PSResourceGetPSModulePath folders
wingetDesktop and command-line applicationsWindows Package ManagerProgram Files or user AppData
ChocolateyApplications wrapped in NuGet packageschoco.exeProgram Files and the Chocolatey folder
ScoopPortable command-line toolsscoopUser profile scoop folder
How the Gallery differs from Windows package managers

Because the Gallery and Chocolatey both build on the NuGet package format, organizations sometimes host both kinds of content on a single internal NuGet server, while keeping them in separate feeds so that clients do not mix modules and applications.

Publishing requires a Gallery account, a personal API key and a module with a valid manifest. The manifest must declare at least a ModuleVersion, an author and a description, and the version must follow semantic versioning, optionally with a prerelease suffix such as -beta1 that clients only install with the -AllowPrerelease or -Prerelease switch.

After upload, the service runs automated validation, including PSScriptAnalyzer rules and an antivirus scan, before the package appears in search results. A published version cannot be overwritten or deleted by its owner; it can only be unlisted, which hides it from search but still allows installation by exact version. This immutability protects scripts that pin a specific version.

  • Store the API key in a secret vault or pipeline variable, never in a script file.
  • Increment the version for every release, because an existing version number cannot be reused.
  • Declare dependencies in RequiredModules so clients install them automatically.
  • Set CompatiblePSEditions to state whether the module supports Desktop, Core or both.

Security risks and safe use of PSGallery

The Gallery is open to any registered publisher, and Microsoft scanning does not amount to a review of intent or quality. For that reason, clients treat PSGallery as an untrusted repository by default and ask for confirmation before installing, a prompt that many administrators suppress without considering what it protects against.

The main risks are typosquatting, abandoned packages taken over by new owners and dependencies that pull in code nobody reviewed. The following table pairs common problems with their causes and remedies.

ProblemLikely causeRecommended fix
Untrusted repository promptPSGallery InstallationPolicy is UntrustedReview the package, then confirm or trust the repository deliberately
Unable to download from URIOld Windows PowerShell without TLS 1.2Enable TLS 1.2 and update PowerShellGet
NuGet provider promptPowerShellGet 1.x on Windows PowerShell 5.1Install the provider or move to PSResourceGet
Module not found after installEdition-specific module folderInstall in the edition that will run it or use AllUsers
Unexpected code in a dependencyUnreviewed transitive packagesInspect with Save-Module before installing
Typical problems and how to address them

In managed environments, the safest pattern is an internal mirror repository: approved module versions are downloaded with Save-Module, reviewed, then published to a private feed that clients register as their primary source. Combined with pinned versions and an appropriate execution policy, this keeps automation reproducible and limits exposure to a compromised upstream package.

The simple explanation

The PowerShell Gallery is like an app store for PowerShell add-ons. PowerShell on Windows can do many things out of the box, but most specialized tasks, such as managing cloud services or testing scripts, need extra commands. Those extra commands come packed in modules, and the Gallery is the shared shelf where people put them.

A single command fetches a module and makes its new commands available. The important point is that anyone can place items on that shelf, so a careful administrator checks who made a module and what it does before installing it, just as one would check an unknown app.

How it is used in practice

An IT team at a mid-sized company manages about 400 Windows laptops and several cloud tenants. Its administrators need the Microsoft Graph and Exchange Online modules, plus Pester for testing their own scripts. Instead of letting every workstation download directly from PSGallery, the team runs Save-Module on a build server, reviews the downloaded versions and publishes them to an internal NuGet feed.

Each administrator workstation registers that internal feed as a trusted repository and installs modules with Install-PSResource using exact version numbers. When a new release of a module appears in the Gallery, one engineer tests it in a lab and then promotes it to the internal feed. The result is that every script runs against the same reviewed module versions, and an accidental typo in a module name can no longer pull an unknown package from the public repository.