customer relationships

How to Automate Software Package Installations in Server 2016 via PowerShell

Here are some of the ways you can automate software package and modules installations in Server 2016, using some of the new package management cmdlets that come with PowerShell.

With the introduction of services like NuGet, Choclatey, PSGet and Package Manager, Windows finally has a great way of delivering software packages and modules directly from the internet or through an internal repository. Here are some of the ways you can automate software package and modules installations in Server 2016, using some of the new package management cmdlets that come with PowerShell.

Let’s first see what commands are available to us. All of the package management commands are in the PackageManagement module.

It looks like we have all the necessary cmdlets to manage software on my Server 2016 machine. I’m currently building a Server 2016 machine for some testing purposes and need a few modules to do some further configuration.

I’d like to get the AzureRm PowerShell module installed. Rather than going out on Github, download all the files and manually placing them in the right folder, let’s use Install-Package to quickly do this directly from PowerShell.

First, I’ll need to find the module in one of the currently configured providers. You can see a list of configured providers by using the Get-PackageProvider cmdlet.

However, I don’t need to know this right off the bat. I can use Find-Package to search through all providers automatically in search of a module or software package that I’m looking for; in this case, the AzureRm module.

I’m going to run Find-Package and provide it the name of the module I’m after. You can see that it found a match in the PowerShell Gallery.

To install this, I pipe that result directly to Install-Package, which will immediately begin installing the module, after I confirm that I trust the PowerShell Gallery as a source.

However, maybe I just want to download it to inspect it before actually installing the module. I could do this by using the Save-Package command and specify the folder path where I’d like to save the package to.

Find-Package –Name AzureRm | Save-Package –Path C:Downloads


But what if I need a piece of software rather than a module? In that case, Chocolatey is the way to go. Chocaletey is a repository of thousands of pieces of software packaged up and ready to be automated. However, installing packages from Chocolatey don’t come by default in Server 2016. We’ll need to add this as a provider first. To do this, I’ll first need to see if it’s available as a provider.

Once I confirm it’s available, I can then download it by using Install-PackageProvider

Next, I’ll need to import it so that I can use it.

And finally, confirm that it’s now an available provider.

Now I can install any software in the Chocolatey repository. Let’s install 7zip as an example. To do that, I’ll run Find-Package and see if a package called 7Zip exists.

I want the entire 7Zip package, so I’ll just download and install the top option. You’ll notice when the install starts, Chocolatey automatically downloads and installs any dependent packages as well. Once I found the package on the Chocolatey repository I piped that to Install-Package.  It then noticed that a couple dependent packages were needed and installed them as well.

That was a lot easier than going out to the Internet, searching for a download link somewhere and installing it that way.
You’ve seen Windows now has a powerful package management system. Whether you need to download PowerShell scripts or modules from the PowerShell Gallery or need to automate software installations, both can be done via the package management cmdlets you can find on Server 2016.

one click social media designs

Leave a Reply

Your email address will not be published. Required fields are marked *