Installing Tools Using Powershell and Chocolatey (Windows)

Rafael Medeiros
3 min readNov 24, 2021

--

Photo by Tetiana Bykovets on Unsplash

There are times where you need to start your job as fast as you can, but you just received a fresh laptop with nothing but the OS installed on it. Or maybe you have just configured a Virtual Machine in the cloud and it’s also empty. How do we speed things up and save time installing all the tools you need? Powershell to the rescue!

But this time, we will be having additional help of Chocolatey, a repository, or a package manager similar to what we already have in Linux (apt,rpm,yum), but this was designed for Windows instead.

Installing Chocolatey

Since we are using Powershell to help us out, let’s perform the installation using Powershell only. Type the following command in an elevated Powershell session:

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

I’ll briefly explain the command:

Set-ExecutionPolicy Bypass -Scope Process -Force; This line will bypass the execution process on this process only;

[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; This block will enable TLS 1.2 protocol;

((New-Object System.Net.WebClient).DownloadString(‘https://community.chocolatey.org/install.ps1')) — This block will download the install.ps1 script and start the installation process.

As stated by the script on the image above, the packages will be installed at C:\ProgramData\chocolatey\lib:

Refer to this document for more installation methods:

Finding Chocolatey Packages

On Chocolatey’s website, you’ll be able to browse and filter the packages you want to install on your machine.

Here you can see what packages are available to download using Chocolatey:

It’s indeed an easy interface to navigate and find everything you’re looking for. As you can see on the image above, they will provide you with the command to install that specific package you choose.

Now that we have Chocolatey installed, we found the packages we want to download to start working in our machines, what about install everything with one script only?

Automating the Packages Installation

I’ve prepared this script to help me to install all the packages I need, you can use it as a reference and change only the packages name:

Uninstalling Packages Using Chocolatey

To Uninstall a package is as simple as install it, just run the following command:

choco uninstall <PackageName>

Wrap Up

This post was intended to show you how to automate the process of installing many tools at once and therefore make your life easier. Do you have better ways to automate the process of installing all the tools you need? Let us know in the comments.

I’ll see you in the next post!Keep studying!

--

--

Rafael Medeiros
Rafael Medeiros

Written by Rafael Medeiros

DevOps Engineer | 3x Azure | Kubestronaut | Terraform Fanatic | Another IT Professional willing to help the community

No responses yet