Get started Bring yourself up to speed with our introductory content.

Use Chocolatey to automate software installations on Windows Server

The Chocolatey package manager enables admins to automate tedious software deployments. Follow these steps to speed up your install process and regain time in your day.

Installing software on a Windows server is a boring, but necessary process. Administrators can use the free package...

manager NuGet and package provider called Chocolatey to automate the task.  

Chocolatey uses NuGet to bundle and distribute various software packages. Admins can enlist Chocolatey to install hundreds of different software packages with this single line in PowerShell:

Install-Package <Software>

But before any of this can happen, admins must install Chocolatey. To do so, open the PowerShell console and run the following command to download a PowerShell script from Chocolatey.org and invoke the script.

iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

PowerShell console
Figure 1: Install Chocolatey from the PowerShell console.

After Chocolatey installs, we can use the choco command to find, inspect, download and install software packages. For this article, let's say the admin wants to install the 7-zip utility on a server. Use the following command to search for available software:
choco search 7-Zip

Choco search
Figure 2: Search with choco to find the software to install.

Looking at the results in Figure 2, we want to install the 7zip 16.02.0.20160811 package. Pass that name to choco install and Chocolatey will download the file and begin the install.

In Figure 3, Chocolatey prompts the admin for permission to complete the installation. In the future, you can use the -y switch to suppress these warnings. 

Choco install
Figure 3: Use the choco install command to download the 7-zip package and start the installation.

 

When removing programs installed by Chocolatey, don't use Programs and Features. Use choco with the uninstall parameter.

In Figure 4, notice the uninstall process was not silent. The admin has to click Uninstall, which is necessary when the package author does not include an automatic uninstall feature.

Choco uninstall
Figure 4: Use the uninstall parameter in choco to uninstall software packages.

 

If a package does not have an automatic uninstall feature, you can build your own Chocolatey packages with that modification or create a new package for your organization's needs.

A choco search calls up several different packages that originate from the internet-hosted public community feed. If your company won't install "untrusted" software, create your own internal repository for Chocolatey to host packages; you also can download packages from the community feed and add them to your company's internal feed. Either way, the process is the same: Choose the source to use with the -source parameter:

choco 7zip -source myinternalfeed.company.local

With Chocolatey, you can automate software installations to remove a few time-consuming tasks from your list. Chocolatey and other NuGet-based package management technologies help reduce deployment time and any inadvertent errors that come with manual intervention.

Next Steps

SharePoint PowerShell commands help ease admin tasks

Use PowerShell DSC to build a web server

Manage Windows services with help from PowerShell and WMI

This was last published in May 2017

Dig Deeper on Windows PowerShell Scripting

PRO+

Content

Find more PRO+ content and other member only offers, here.

Join the conversation

1 comment

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

What will you do with your time once you automate server installations?
Cancel

-ADS BY GOOGLE

SearchServerVirtualization

SearchCloudComputing

SearchExchange

SearchSQLServer

SearchWinIT

SearchEnterpriseDesktop

SearchVirtualDesktop

Close