PowerShell

PowerShell: Install Software via Online Repository (Chocolatey)

Chocolatey is an Online Respository for popular software products. Online repositories provide a convenient way to install software, such as Adobe Reader, WinZip … It is also possible to install multiple software at once. In this blog post I will carry out installing chocolatey and perfrom some action with it. Let’s dive in.

Install Chocolatey

First of all we need to install the package manager. In order to do this we are supposed to set the PowerShell execution policy to bypass. Don’t worry, the setting will be changed for this session only.

Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass

Next, install chocolatey via the WebClient.

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

Fine. We are now ready to perform some action.

Find Software

Build on the examples below to find the software you are looking for. Use the find parameter.

choco find googlechrome

choco find adobereader

Use the info parameter to find more about your software product.

choco info googlechrome

Install Software

Once you have found your product, install it. You are able to install multiple software products at once. The -y parameter installs the products in silent mode.

choco install googlechrome adobereader -y

Upgrade Software

To install updates, specify the package name and use the upgrade parameter.

Don’t worry about the red ones here. It’s all good 😉

choco upgrade googlechrome adobereader -y

List installed Software

For getting an overview, use choco list -lo.

choco list -lo

Install Software on multiple Computers

This part is just to give you thoughts for ideas. This will not actually work. Why? Chocolatey limits downloads per IP address to one IP in a given time to avoid denial of service attacks. To get around this, create your own repository without restrictions. Nevertheless, I will show you where the journey would go.

Installing a software product on all Windows 10 computers in a specific OU.

$Computers = Get-ADComputer -Filter * `
-SearchBase "OU=Windows 10,DC=domain,DC=com" | 
Select-Object -ExpandProperty Name

Invoke-Command -ComputerName $Computers -ScriptBlock {

    choco install googlechrome -y 

}

Cool stuff.

Thank you for reading this article.

See also

Categories: PowerShell

Tagged as: ,

1 reply »

  1. How can you verify chocolatey?
    I mean I still don’t trust online repos.
    How manages these repos?
    How can I be sure that the software in the repo is from original sources and is not compromised?

    Maybe I did not do enough research about this.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.