Home » PowerShell » Find-Package in PowerShell

Find-Package in PowerShell

The `Find-Package` is a cmdlet in the PowerShell PackageManagement module. It is used to find software packages in available repositories. These repositories can include the PowerShell gallery, Chocolatey, Nuget, and many others.

Here is a PowerShell command to find packages in the available repositories.

Find-Package *

The Find-Package command in the PowerShell PackageManagement module can be used to find all available packages from a package provider, find a package from a package source, find all versions of a package, and find a package with a specific name.

In this article, we will discuss how to use the Find-Package cmdlet in Powershell to search for packages in the available repositories.

How to Find All Available Packages from a Package Provider

To find all available packages from a package provider, use the Find-Package command with the –ProviderName parameter.

Find-Package -ProviderName PowerShellGet

In the above PowerShell script, the Find-Package command uses the ProviderName parameter to specify the provider PowerShellGet and finds all the available PowerShell module packages in a registered PSGallery.

The output of the above PowerShell script to list all packages is given below.

PowerShell List all packages
PowerShell List all packages

How to Find a Package from a Package Source

Use the Find-Package command along with the Source parameter to find a package from a specified package source.

Find-Package -Name Az.Postgresql  -Source PSGallery  

In the above PowerShell script, the Find-Package command uses the Name parameter to specify the package name “Az.Postgresql” and the Source parameter to specify the package source “PSGallery“. This command finds the newest version of a package from a specified package source.

The output of the above PowerShell script that searches for a package name from a package source is given below.

PS C:\> Find-Package -Name Az.Postgresql  -Source PSGallery    
                                                                                   
Name                           Version          Source           Summary
----                           -------          ------           -------
Az.PostgreSql                  1.1.0            PSGallery        Microsoft Azure PowerShell: PostgreSql cmdlets


PS C:\>                                                                                                                                                      

How to Find All Versions of a Package

To find all versions of a package, use the Find-Package command with parameter AllVersions.

Find-Package -Name Az.Postgresql  -Source PSGallery -AllVersions

In the above PowerShell script, the Find-Package cmdlet uses the Name parameter to specify the package name “Az.Postgresql” and the Source “PSGallery“. It then uses the AllVersions parameter to retrieve all available versions of a package.

The output of the above PowerShell script finds all available package versions from a specified provider is given below.

PS C:\> Find-Package -Name Az.Postgresql  -Source PSGallery -AllVersions                                                                          
Name                           Version          Source           Summary
----                           -------          ------           -------
Az.PostgreSql                  1.1.0            PSGallery        Microsoft Azure PowerShell: PostgreSql cmdlets
Az.PostgreSql                  1.0.0            PSGallery        Microsoft Azure PowerShell: PostgreSql cmdlets
Az.PostgreSql                  0.8.0            PSGallery        Microsoft Azure PowerShell: PostgreSql cmdlets
Az.PostgreSql                  0.7.0            PSGallery        Microsoft Azure PowerShell: PostgreSql cmdlets
Az.PostgreSql                  0.6.0            PSGallery        Microsoft Azure PowerShell: PostgreSql cmdlets
Az.PostgreSql                  0.5.0            PSGallery        Microsoft Azure PowerShell: PostgreSql cmdlets
Az.PostgreSql                  0.4.0            PSGallery        Microsoft Azure PowerShell: PostgreSql cmdlets
Az.PostgreSql                  0.3.0            PSGallery        Microsoft Azure PowerShell: PostgreSql cmdlets
Az.PostgreSql                  0.2.0            PSGallery        Microsoft Azure PowerShell: PostgreSql cmdlets
Az.PostgreSql                  0.1.0            PSGallery        Microsoft Azure PowerShell: PostgreSql cmdlets


PS C:\>     

How to Find a Package With a Specific Name

You can use the Find-Package command in PowerShell to find a package with a specific name from a specified provider.

Find-Package -Name PackageManagement -ProviderName PowerShellGet -RequiredVersion 1.3.1   

In the above PowerShell script, the Find-Package command uses the Name parameter to specify the package name “PackageManagement“. The ProviderName parameter specifies to search for the package in “PowerShellGet“. RequiredVersion specified to check for version 1.3.1 only and return the result.

The output of the above PowerShell script finds a specific package version from a specified provider.

PS C:\> Find-Package -Name PackageManagement -ProviderName PowerShellGet -RequiredVersion 1.3.1    
                                               
Name                           Version          Source           Summary
----                           -------          ------           -------
PackageManagement              1.3.1            PSGallery        PackageManagement (a.k.a. OneGet) is a new way to discover and install softwa...


PS C:\>      

Conclusion

I hope the above article on how to use the Find-Package command in the PowerShell module to search for packages in the provider is helpful to you.

You can find more topics about PowerShell Active Directory commands and PowerShell basics on the ShellGeek home page.

Related Links

Get-Package

Get-PackageProvider

Install-Package

Install NuGet Package

Get-PackageSource

Register-PackageSource