How to Install Chocolatey on Windows Server 2012, 2019

Estimated reading: 3 minutes 137 views

Introduction

Chocolatey or Choco as it is sometimes referred to is a free, open-source package manager for Windows that is very similar to Apt or DNF in the Linux realm. In other words, this is a program used for installing software via the Windows command line. Chocolatey’s simple and familiar syntax is easy to learn and can save heaps of time when setting up a new environment.
In this article, we will show you how to install Chocolatey on a Windows VPS.

Prerequisites

  • an active Windows VPS
  • PowerShell v2 or later
  • .NET Framework 4 or later

Installing Chocolatey

Let’s move on to the installation. There are two options for installing Chocolatey. We can install Chocolatey via the command line or through PowerShell. The option to use cmd is most often used for Windows, and PowerShell for running scripts. In this case, we can run both cmd and PowerShell, but as an administrator, for this installation.

Option 1: Install Using CMD

Open an administrative command prompt (right-click Start -> Command Prompt (administrator)) and type the following command:

@"%SystemRoot%System32WindowsPowerShellv1.0powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "[System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%chocolateybin"

Verify Installation

To verify that Chocolatey is installed, we will use the Choco command.

C:WINDOWSsystem32>choco
Chocolatey v0.11.2
Please run 'choco -?' or 'choco  -?' for help menu.

Excellent! Chocolatey is installed!

Option 2: Install Using Powershell

Open an administrative PowerShell prompt (right-click Start -> Windows PowerShell (administrator)) and type the following command:

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

If there are no errors, Chocolatey will be installed. We can verify the installation using the choco or choco -? command.

Basic Chocolatey Commands

Now let’s review some of the basic commands for using Choco. Choco commands can be used in both the Windows cmd shell and in PowerShell.

There are hundreds of packages that you can browse on the Chocolatey website https://chocolatey.org/packages or by running:

choco list

To install a package, open an administrative command prompt or PowerShell session and type the following command:

choco install  -y

For example:

choco install firefox -y

Chocolatey will also install any dependencies automatically. You can also include multiple packages in one command to minimize waiting:

choco install firefox adobereader jre8 -y

Update Program

To update a program, we will use the following command.

choco upgrade  -y

For example:

choco upgrade firefox -y

Update All Programs

To update all programs, we need to use the following command.

choco upgrade all -y

Search For a Program

To find a needed program for downloading and installation, we can enter the following command.

choco search firefox

See Installed Programs

Using the following command, you can see which programs are already installed using Choco.

choco list --local-only

Update Chocolatey

We can update the Choco program itself using this command.

choco upgrade chocolatey

It is important to do this periodically because in previous versions, errors may be detected, and they need to be fixed so that there are no vulnerabilities.

Uninstalling packages/Chocolatey

Packages are removed similarly to how they are installed. Run the following command to uninstall your chosen package:

choco uninstall 

You can even uninstall Chocolatey itself with this command:

choco uninstall chocolatey

And that’s it! Enjoy GreenCloudVPS services!


Click here to get started!!!

Leave a Comment