Home » PowerShell » Get-Package in PowerShell

Get-Package in PowerShell

The `Get-Package` command in PowerShell returns a list of all packages on the system that were installed with `PackageManagement`.

Here is the command to get packages on the system.

Get-Package

The Get-Package cmdlet returns a list of all software packages, gets packages for a specific provider, gets an exact version of a specific package, and gets packages that are installed on a remote computer using the Invoke-Command.

In this article, we will discuss how to use Get-Package in PowerShell to get all packages that were installed with PackageManagement.

How to Get a List of All Software Packages on the Local Computer

Use the Get-Package cmdlet in PowerShell to get a list of all software packages on the local computer that were installed with the PackageManagement module.

Get-Package

The above PowerShell command returns a list of all packages that are installed on the local computer.

Get Packages in the System
Get Packages in the System

How to Get Packages for a Specified Provider in PowerShell

The command to get packages for a specified provider such as PowerShellGet is Get-Package with the –ProviderName parameter.

 Get-Package -ProviderName PowerShellGet -AllVersions 

In the above PowerShell script, the Get-Package command uses the ProviderName parameter to specify the specified provider “PowerShellGet“. The AllVersions parameter displays each version that is installed.

The output of the above PowerShell script to get packages for a specified provider is given below.

PS C:\> Get-Package -ProviderName PowerShellGet -AllVersions                                                                                                                                 
Name                           Version          Source                           ProviderName
----                           -------          ------                           ------------
FileSplitter                   1.3              https://www.powershellgallery... PowerShellGet
PSWindowsUpdate                2.2.0.3          https://www.powershellgallery... PowerShellGet

How to Get an Exact Version of a Specific Package using PowerShell

You can use the Get-Package cmdlet with the RequiredVersion parameter to get an exact version of a specific package in a specified provider.

Get-Package -Name FileSplitter -ProviderName PowerShellGet -RequiredVersion 1.3 

In the above PowerShell script, the Get-Package command gets an exact version of the package “FileSplitter” from a PowwerShellGet provider. The RequiredVersion parameter is used to specify the version that you need to retrieve.

The output of the above PowerShell script gets a specific version of an installed package.

PS C:\> Get-Package -Name FileSplitter -ProviderName PowerShellGet -RequiredVersion 1.3                                                                                                      
Name                           Version          Source                           ProviderName
----                           -------          ------                           ------------
FileSplitter                   1.3              https://www.powershellgallery... PowerShellGet

How to Get Packages that are Installed on Remote Computer

To get packages that are installed by PackageManagement on the remote computer, use the Invoke-Command cmdlet. The Invoke-Command uses the ComputerName parameter to specify a remote computer name.

The Credential parameter specifies a domain and user name with permissions to run commands on the remote computer.

The ScriptBlock parameter runs the Get-Package cmdlet to get all the packages on the remote computer.

PS> Invoke-Command -ComputerName INCORP-EU-01 -Credential SHELLPRO\Gary -ScriptBlock {Get-Package}

Conclusion

I hope the above article on how to use the Get-Package command to get all the packages installed by the PackageManagement module is helpful to you.

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

Related Links

Find-Package

Get-PackageProvider

Install-Package

Install NuGet Package

Get-PackageSource

Register-PackageSource

Get-Help