Automation is the king of the world of IT operations today. There are so many great scripting and other platforms that allow operations to efficiently automate much of the infrastructure and network. With Windows Server, PowerShell is certainly a great way to perform any kind of automation, especially with package management. There are many different kinds of package management systems available by means of PowerShell to install, update, manage, and remove packages. With Windows Server 2019, this is no exception. Using PowerShell package management administrators have a great way to automate Windows Server 2019 package management.

Let’s take a look at various ways and systems that can be used with PowerShell to automate package management in Windows Server 2019.

PowerShell Facilitating Package Management for Windows

One of the strong suits of Linux has always been the ability to perform package management by means of the command line and have an easy way to install new packages, keep installed packages updated, as well as remove packages. This ability in Linux has always greatly served various automation use cases.

In previous years, Windows Server has lagged far behind Linux in these types of areas in terms of manageability and the ability to automate these kinds of tasks. However, since the introduction and integration of PowerShell into modern versions of Windows, this has opened up a whole new set of capabilities based on PowerShell’s powerful hooks into the internals of Windows. Additionally, PowerShell is extremely extensible which has led to many package management tools and modules being built as we will see.

With PowerShell and Package management, Windows Server administrators can now come much closer to being able to manage Windows Server much more like a Linux server with powerful automation capabilities to keep packages updated, managed, and configured. Let’s now take a look at a few of the PowerShell specific commands that can be used to manage Windows Server packages effectively.

Download Banner

Automate Windows Server 2019 Package Management with PowerShell

As mentioned, PowerShell is included in modern Windows Server versions such as Windows Server 2019. Along with PowerShell being included, there are PowerShell modules already loaded that allow easily managing packages right out of the box. Windows Server 2019 contains the PackageManagement module that allows various actions including the following:

  • Finding packages
  • Getting Packages
  • Getting Package Providers
  • Getting Package Sources
  • Importing Package Providers
  • Installing Packages
  • Registering Package Sources
  • Saving Packages
  • Setting Package Source
  • Uninstalling Packages
  • Unregistering Package Sources

This PackageMangement cmdlet is a tool used in Windows Server to manage repositories so you can search for, install, update, or remove packages.


Windows Server 2019 PowerShell Packagemanagement modules

Let’s take a look at one of these, the Get-PackageProvider cmdlet to see what package providers are installed in our Windows Server 2019 test server.

  • Get-PackageProvider


Using the get-packageprovider to see currently installed package providers

To find Package providers on your Windows Server 2019 server available for install by default, use the following cmdlet:

  • Find-PackageProvider | ft -autosize


Finding available packages that can be installed in Windows Server 2019

Let’s look at installing a popular package provider, Chocolatey and see how this is done. It is very simple using the built-in PowerShell package management cmdlets.

  • Install-PackageProvider -Name Chocolatey


Installing Chocolatey using Windows Server 2019 PowerShell package management modules

Using PowerShell Repositories for Loading Software Packages

As there exists in the world of Linux, PowerShell has at its disposal repositories for use with loading and managing packages to be installed in Windows Server. To work with these external repositories, there is a special cmdlet that is useful in this regard in PowerShell called the PowerShellGet module.

PowerShellGet uses the main PSGallery repository for loading packages. This is the “official” repository for lack of a better term for loading packages as it is supported by Microsoft and has Microsoft as a contributor to the repository.

The Install-PackageProvider is a PowerShell module for installing Package Management providers that are available in package sources registered with PowerShellGet. By default, this includes modules available in the PowerShell Gallery with the PackageManagement cmdlet.

In addition to using outside PowerShell repositories, you can create your own repository for use with PowerShell package management. You can do this easily and for free using the Register-PSRepository cmdlet to configure a PowerShell repository for use with package management. You can interact with the custom repository and publish your own custom modules to the repository using the Publish-Module cmdlet.

PowerShell Security to Ensure PowerShell Scripts are Safe

There isn’t a bigger topic in the world of IT Operations than security. It should be considered in all aspects of managing the enterprise environment. Even with PowerShell scripts, security plays a large factor in how, if, and when they are run. PowerShell has built-in capabilities to test PowerShell scripts to ensure they are safe to run by validating the digital signature on the script by using the execution policy functionality. The execution policy determines whether the script has a valid signature and if that signature has been changed for some reason. This goes a long way in helping to prevent malicious tampering of scripts.

To configure PowerShell to test the digital signature of all scripts you use the following cmdlet:

  • Set-ExecutionPolicy -AllSigned

A step down from PowerShell checking all scripts is having it check the digital signature only on scripts that have been downloaded. To configure PowerShell for this level of signature checking to use the following:

  • Set-ExecutionPolicy -RemoteSigned

Concluding Thoughts

Automating Windows Server 2019 package management with PowerShell is a powerful way to streamline and begin instantiating DevOps type processes in managing and maintaining Windows Server environments. Much like Linux package management, PowerShell allows IT administrators to install, update, modify, and even remove packages from Windows Server. Additionally, there is the concept of using repositories much like Linux to add sources of packages to add/manage and use as install sources. All of these types of operations are available to run from the PowerShell command line. By utilizing the automation features and strengths of PowerShell, businesses can manage and operate Windows Server environments in a much more efficient, effective, and automated way.

Follow our Twitter and Facebook feeds for new releases, updates, insightful posts and more.

Like what you read? Rate us
Automating Windows Server 2019 Package Management with PowerShell
Rate this post