
The PowerShell Gallery
The PowerShell Gallery is the central public repository for PowerShell modules, scripts, and other resources. It’s a hub where developers, IT professionals, and enthusiasts share their work, making it easier for others to find and use pre-built solutions. The gallery is sponsored and funded by Microsoft, ensuring its reliability and accessibility.
What is the PowerShell Gallery?
The PowerShell Gallery is a repository that hosts:
Modules: Collections of cmdlets, functions, and other resources.
Scripts: Standalone PowerShell scripts for specific tasks.
DSC Resources: Desired State Configuration resources for automating system configurations.
It includes contributions from Microsoft, third-party companies, and the PowerShell community. Many projects on the gallery originate from GitHub, where they are developed as open-source projects.
Accessing the PowerShell Gallery
You can access the PowerShell Gallery in two ways:
Via the Website: Visit www.PowerShellGallery.com to browse and search for modules and scripts.
Via PowerShell: Use PowerShell cmdlets to search, download, and install modules and scripts directly from the gallery.
Searching the PowerShell Gallery
Using the Website
The website allows you to filter and search for modules and scripts using keywords. It’s user-friendly and provides detailed information about each item, including version history, dependencies, and installation instructions.
Using PowerShell
You can search the gallery directly from PowerShell using the following cmdlets:
Find-Module: Searches for modules.
Find-Script: Searches for scripts.
For example:
Find--Name "Azure"
This command searches for modules related to Azure.
Downloading and Installing Modules/Scripts
Saving Modules/Scripts
To download a module or script without installing it, use:
Save-Module -Name SomeModule -Path C:\SomeLocalFolder
Save-Script -Name SomeScript -Path C:\SomeLocalFolder
This saves the module or script to the specified folder for testing or offline use.
Installing Modules/Scripts
To install a module or script for use in PowerShell, use:
For Current User (does not require admin rights):
Install-Module -Scope CurrentUser -Name SomeModule Install-Script -Scope CurrentUser -Name SomeScript
For All Users (requires admin rights):
Install-Module -Scope AllUsers -Name SomeModule Install-Script -Scope AllUsers -Name SomeScript
Default Installation Paths
Modules:
Current User:
$env:USERPROFILE\Documents\WindowsPowerShell\Modules
All Users:
$env:ProgramFiles\WindowsPowerShell\Modules
Scripts:
Current User:
$env:USERPROFILE\Documents\WindowsPowerShell\Scripts
All Users:
$env:ProgramFiles\WindowsPowerShell\Scripts
Managing Installed Modules/Scripts
Listing Installed Modules/Scripts
To see which modules and scripts are installed from the gallery:
Get-InstalledModule
Get-InstalledScript
Updating Modules/Scripts
To update all installed modules and scripts:
Update-Module
Update-Script
To update a specific module or script:
Update-Module -Name SomeModule
Update-Script -Name SomeScript
Uninstalling Modules/Scripts
To remove a module or script:
Uninstall-Module -Name SomeModule
Uninstall-Script -Name SomeScript
Overlapping Names
If two modules contain functions or cmdlets with the same name, the last module loaded takes precedence. To avoid conflicts, you can explicitly call a function or cmdlet from a specific module using the module name as a namespace:
Module1\Ping
Module2\Ping
PowerShellGet and PackageManagement
The PowerShellGet module provides cmdlets for interacting with the PowerShell Gallery. Under the hood, it relies on the PackageManagement module, which handles package providers and sources.
Package Providers
A package provider is a DLL that allows PowerShell to work with specific package formats (e.g., NuGet, MSI). To see installed providers:
Get-PackageProvider
Package Sources
A package source is a repository (like the PowerShell Gallery or NuGet) that hosts packages. To see available sources:
Get-PackageSource
NuGet and Other Repositories
NuGet is a popular package manager for .NET developers. It’s also integrated with PowerShell, allowing you to search and install NuGet packages:
Find-Package -Source nuget.org -Name "*Numerics*"
Install-Package -Source nuget.org -Name "MathNet.Numerics" -Destination C:\SomeFolder
Snap-Ins (Deprecated)
Before modules, PowerShell used snap-ins to extend functionality. Snap-ins are compiled DLLs that require installation and registry modifications. While still supported, they are deprecated in favor of modules.
Listing Snap-Ins
To see loaded snap-ins:
Get-PSSnapin
Loading Snap-Ins
To load a snap-in:
Add-PSSnapin Quest.ActiveRoles.ADManagement
Last updated