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.
How the PowerShell Gallery delivers packages
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.
| Task | PowerShellGet cmdlet | PSResourceGet cmdlet |
|---|---|---|
| Search for a package | Find-Module, Find-Script | Find-PSResource |
| Install a package | Install-Module, Install-Script | Install-PSResource |
| Update installed packages | Update-Module | Update-PSResource |
| Download without installing | Save-Module | Save-PSResource |
| Publish a package | Publish-Module | Publish-PSResource |
| Register another repository | Register-PSRepository | Register-PSResourceRepository |
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 type | What it contains | Typical use |
|---|---|---|
| Module | Cmdlets, functions and a .psd1 manifest | Reusable tooling such as cloud or directory management |
| Script | A single .ps1 file with metadata | One-off automation or setup routines |
| DSC resource | Desired State Configuration resources inside a module | Declarative server configuration |
| Role capability | Definitions for Just Enough Administration | Restricted remote administration endpoints |
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.
PowerShell Gallery compared with winget, Chocolatey and Scoop
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.
| Repository | What it distributes | Client | Typical install location |
|---|---|---|---|
| PowerShell Gallery | Modules, scripts, DSC resources | PowerShellGet or PSResourceGet | PSModulePath folders |
| winget | Desktop and command-line applications | Windows Package Manager | Program Files or user AppData |
| Chocolatey | Applications wrapped in NuGet packages | choco.exe | Program Files and the Chocolatey folder |
| Scoop | Portable command-line tools | scoop | User profile scoop folder |
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 a module to the Gallery
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.
| Problem | Likely cause | Recommended fix |
|---|---|---|
| Untrusted repository prompt | PSGallery InstallationPolicy is Untrusted | Review the package, then confirm or trust the repository deliberately |
| Unable to download from URI | Old Windows PowerShell without TLS 1.2 | Enable TLS 1.2 and update PowerShellGet |
| NuGet provider prompt | PowerShellGet 1.x on Windows PowerShell 5.1 | Install the provider or move to PSResourceGet |
| Module not found after install | Edition-specific module folder | Install in the edition that will run it or use AllUsers |
| Unexpected code in a dependency | Unreviewed transitive packages | Inspect with Save-Module before installing |
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.