Get Package - PowerShell
Overview
Get-Package retrieves details about installed PowerShell packages from the specified feed or repository. These packages represent modules, scripts, or other resources that extend PowerShell’s functionality.
Syntax
Get-Package [-Name] <string> [-RequiredVersion] <string> [-ProjectName] <string> [-AllVersions] [-AllDependencies] [-LatestVersion] [-SkipPublisherCheck] [-AllowPrerelease] [-IncludeDependencies] [-ListAvailable] [-ProviderName] <string> [-ProviderVersion] <string> [-ErrorAction] <ActionPreference> [-WarningAction] <ActionPreference> [-InformationAction] <ActionPreference> [-Verbose] [-Debug] [-OutVariable] <string> [-OutBuffer] <bool>
Options/Flags
| Option/Flag | Description | Default | Typical Use |
|—|—|—|—|
| -Name | Specifies the name of the package to find. | – | Find a specific package. |
| -RequiredVersion | Filters results to packages with a specific version. | – | Find a package with a desired version. |
| -ProjectName | Returns details of the installed package projects. | – | Show details of packages associated with a project. |
| -AllVersions | Includes all versions of a package in the results. | $false | Show all versions of a package. |
| -AllDependencies | Includes all dependent packages in the results. | $false | Show the dependencies of a package. |
| -LatestVersion | Only returns the latest version of a package. | $false | Find the newest version of a package. |
| -SkipPublisherCheck | Bypasses publisher verification, allowing packages from untrusted sources. | $false | Install packages from non-official repositories. |
| -AllowPrerelease | Includes prerelease versions of packages in the results. | $false | Find prerelease packages for testing. |
| -IncludeDependencies | Includes dependent packages in the results. | $true | Show the dependencies of a package. |
| -ListAvailable | Retrieves packages from available feeds, excluding installed packages. | $false | Find packages available for installation. |
| -ProviderName | Filters results to packages from a specific provider. | – | Find packages from a particular provider. |
| -ProviderVersion | Specifies the version of a provider to use when searching for packages. | – | Use a specific provider version for package discovery. |
| -OutVariable | Stores the result in a specified variable. | – | Save the package details to a variable for further use. |
Examples
Find a specific package
Get-Package -Name Microsoft.PowerShell.Management
Find packages with a specific version
Get-Package -Name Microsoft.PowerShell.SDK -RequiredVersion 0.6.0
List all versions of a package
Get-Package -Name Microsoft.PowerShell.Utility -AllVersions
Find packages that depend on a specific package
Get-Package -ProjectName SqlServer -AllDependencies
Retrieve available packages from a specific provider
Get-Package -ProviderName NuGet -ListAvailable
Common Issues
Error: Package not found
Ensure that the -Name parameter matches the exact package name and that the package is available in the specified repository. If not, try using -ListAvailable to find packages matching the name.
Error: Package already installed
Use -Force parameter to install packages even if they are already installed.
Integration
Combine Get-Package with other commands to manage PowerShell packages:
Install a package
Find-Package -Name MyPackage | Install-Package
Update a package
Get-Package -Name MyPackage -LatestVersion | Update-Package
Uninstall a package
Get-Package -Name MyPackage | Uninstall-Package