Using Chocolatey for Windows
Intro
Well, let's begin with the basic question: "What would Chocolatey be?". Just as simple as the question, is the answer: "It is a package manager developed for Windows".
Yes, we have now (not exactly now, because this project has been rolling approximately since 2014) a package manager for Windows like apt-get or yum for Linux, or Homebrew for Mac. And just as the mentioned, we can use it in infrastructure automation tools (or IaC — Infrastructure as code) like Puppet, Chef or Ansible.
Requirements
- Windows 7 or higher / Windows Server 2003 or higher
- Powershell v2 or higher
- .NET Framework 4 or higher (the Chocolatey installation will try to install this dependency in case you don't have it)
Installing
First thing to do is run as administrator Powershell or Cmd, to do so, search for Powershell or Cmd in Start Menu, right button click and select "Run as Administrator".
For Powershell use the following command line:
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
For Cmd use this command line:
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
Usage
And… done, the installation was just that. Now let's have a look at the basic commands to manage packages:
Search packages
choco search <package approximate name>
or visit https://chocolatey.org and search
List installed packages
choco list --local-only
Installing packages
choco install <package name>
note.: Use -y if you wish to ignore the confirmation messages
Removing packages
choco uninstall <package name>
note.: Use -y if you wish to ignore the confirmation messages
Updating packages
choco upgrade <package name>
to update all your packages use:
choco upgrade all
note.: Use -y if you wish to ignore the confirmation messages
Conclusion
Chocolatey came to ease our life as Windows users and specially Windows administrators. Also made Windows environments more viable when using devops CI/CD tools.
See you soon!
Originally published at https://blog.danielpadua.dev on May 5, 2019.