Find Package - PowerShell
Overview
Find-Package searches for packages (modules, DSC resources, etc.) from available package sources and allows you to install, update, or remove them. It simplifies package management in PowerShell, providing a convenient way to discover, acquire, and manage software components.
Syntax
Find-Package [-Name] <Package Name> [-RequiredVersion] <Version> [-AllVersions] [-LatestVersion] [-Source] <Source Name> [-IncludeDependencies] [-ExcludeDependencies] [-SkipDependencyResolution] [-MinimumVersion] <Version> [-MaximumVersion] <Version> [-AllowPrerelease] [-IgnoreDependencies] [-Literal] [-Recurse] [-Force] [-Verbose] [-Confirm] [-WhatIf] [-PassThru]
Options/Flags
| Option | Description |
|—|—|
| -Name | Specifies the name of the package to search for. |
| -RequiredVersion | Filters packages by the specified version. |
| -AllVersions | Returns all versions of the package, including prerelease versions. |
| -LatestVersion | Finds only the latest version of the package. |
| -Source | Specifies the package source to search in. |
| -IncludeDependencies | Resolves and includes required dependencies within the search results. |
| -ExcludeDependencies | Excludes dependencies from the search results. |
| -SkipDependencyResolution | Ignores dependency resolution during the search. |
| -MinimumVersion | Filters packages with versions greater than or equal to the specified value. |
| -MaximumVersion | Filters packages with versions less than or equal to the specified value. |
| -AllowPrerelease | Includes prerelease versions in the search results. |
| -IgnoreDependencies | Ignores all dependencies when searching for packages. |
| -Literal | Interprets the -Name parameter literally, without wildcard expansion. |
| -Recurse | Recursively searches for packages in nested sources. |
| -Force | Forces the operation to complete, ignoring any errors. |
| -Verbose | Provides verbose output during the search and installation process. |
| -Confirm | Prompts for confirmation before performing the operation. |
| -WhatIf | Shows what would happen if the operation were executed, without actually performing it. |
| -PassThru | Returns the found package objects instead of displaying them. |
Examples
- Search for a specific package:
Find-Package -Name MyPackage
- Search for all versions of a package:
Find-Package -Name MyPackage -AllVersions
- Search for the latest version of a package:
Find-Package -Name MyPackage -LatestVersion
- Search for packages from a specific source:
Find-Package -Name MyPackage -Source PSGallery
- Recursively search nested sources:
Find-Package -Name MyPackage -Recurse
Common Issues
- Package not found: Ensure the package name is correct and the source contains the package. Use
-AllVersionsto search all versions. - Dependency resolution issues: Resolve and include dependencies using the
-IncludeDependenciesoption. - Access denied errors: Ensure you have sufficient permissions to access the package source.
Integration
- Package Management: Install, update, and remove packages using
Install-Package,Update-Package, andRemove-Package. - Script Automation: Automate package management tasks by incorporating
Find-Packageinto PowerShell scripts. - Integration with Package Providers: Use the
Register-PackageProvidercmdlet to add custom package sources and extend package management capabilities.
Related Commands
- [Get-Package]({% link Get-Package %}): Retrieves information about installed packages.
- [Install-Package]({% link Install-Package %}): Installs a package from a specific source.
- [Update-Package]({% link Update-Package %}): Updates an installed package to the latest version.