PowerShell PackageManagement

In this tutorial we will see about PowerShell PackageManagement and how we are able to use it.

What is PackageManagement

PackageManagement is also known as OneGet. PackageManagement has been introduced in Windows PowerShell 5.0. PackageManagement comes with Windows 10 and Windows Server 2016. It is a unified interface to package management systems and aims to make Software Discovery, Installation and Inventory (SDII) work via a common set of cmdlets (and eventually a set of APIs). Regardless of the installation technology underneath, users can use these common cmdlets to install/uninstall packages, add/remove/query package repositories, and query a system for the software installed.

PackageManagement works with:

Package providers

Package sources

Packages

Below is the architecture of PackageManagement exactly as provided in project site:

[adinserter name=”In Article”]

PackageManagement Terms

Package manager – Software package management system. In PackageManagement terms, this is a package provider.

– Software package management system. In PackageManagement terms, this is a package provider. Package provider – PackageManagement term for a package manager. Examples can include Windows Installer, Chocolatey, and others.

– PackageManagement term for a package manager. Examples can include Windows Installer, Chocolatey, and others. Package source – A URL, local folder, or network shared folder that you configure package providers to use as a repository.

– A URL, local folder, or network shared folder that you configure package providers to use as a repository. Package – A piece of software that a package provider manages, and that is stored in a specific package source.

Requirments

Windows 10, Windows Server 2016, or down-level Windows OS + WMF5

Linux or Mac with the PowerShellCore

What you can do with PackageManagement

Manage a list of software repositories in which packages can be searched, acquired, and installed

Search and filter your repositories to find the packages you need

Seamlessly install and uninstall packages from one or more repositories with a single PowerShell command

Now lets see the the cmdlets that PackageManagement provides you, in order to manage software on our systems.

[adinserter name=”In Article”]

PackageManagement cmdlets

We are able to see the commands that are included in PackageManagement by using the below:

Code:

Get-Command -Module PackageManagement

Output:

Commands List:

Find-Package – Finds software packages in available package sources.

Find-PackageProvider – Returns a list of Package Management package providers available for installation.

[adinserter name=”In Article”]

Get-Package – Returns a list of all software packages that have been installed by using Package Management.

Get-PackageProvider – Returns a list of package providers that are connected to Package Management.

Get-PackageSource – Gets a list of package sources that are registered for a package provider.

Import-PackageProvider – Adds Package Management package providers to the current session.

– Adds Package Management package providers to the current session. Install-Package – Installs one or more software packages.

– Installs one or more software packages. Install-PackageProvider – Installs one or more Package Management package providers.

Register-PackageSource – Adds a package source for a specified package provider.

– Adds a package source for a specified package provider. Save-Package – Saves packages to the local computer without installing them.

– Saves packages to the local computer without installing them. Set-PackageSource – Replaces a package source for a specified package provider.

– Replaces a package source for a specified package provider. Uninstall-Package – Uninstalls one or more software packages.

– Uninstalls one or more software packages. Unregister-PackageSource – Removes a registered package source.

[adinserter name=”In Article”]

Install PackageManagement

From PowerShell 5.0 and later, PacakgeManagement is included. You may have to update the module. From the screenshot above we can see that the version that I have installed is 1.1.7.2. Currently the latest stable version is 1.1.7.2. PackageManagement 1.2.0-preview is also available if you would like to install it.

Code:

Install-Module PackageManagement

If you already have PackageManagement installed and you want to update your current installation to the latest one, then you need to use -Force parameter. If you do not use -Force parameter, it will give you an error that module is already installed.

Code:

Install-Module PackageManagement -Force

[adinserter name=”In Article”]

Trusted and Untrusted Sources

As you can see in the screenshot of Get-PackageSource above, the sources are not trusted. When you are trying to install as package from an untrusted source, it will ask you to confirm every time you install a package. If you want not to confirm every time you can set the source as trusted. You can do it by using the below:

Set-PackageSource -Name <sourcename> -Trusted

Output:

If you want to set a trusted source as untrusted, then you will need to use the below:

Code:

Set-PackageSource -Name <sourcename> -Trusted:$false

Output:

The above tutorial is a basic information about PackageManagement that can help you manage software packages on computers and servers. It would be good to check it further in order to understand better what you are able to do with it. In related links section you are able to find links with a lot of information related to PackageManagement.

I hope the tutorial about PackageManagement is helpful.

Please let me know your comments and thoughts.

You feedback is appreciated.

[adinserter name=”In Article”]

Related Links

[adinserter name=”Matched-Content”]