Use Chocolatey in Windows Powershell to Install Programs
Chocolatey is the Windows version of Linux’s apt
or dnf
.
Open Administrator Powershell.
Set up $profile in PowerShell
See the contents of $profile
:
Write-Host $profile
This only shows the variable’s content but the file doesn’t exist there:
C:\Users\...\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
Create the file as seen in the Microsoft docs here:
New-Item -Path $profile -ItemType "file" -Force
Install Chocolatey
Install Chocolatey as seen in the official docs here.
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'))
Even though, the docs don’t fully explain exactly what this does. Here is a short summary form ChatGPT:
...this command sets up the PowerShell environment to allow the execution of scripts without any restrictions, updates the security protocol used for connecting to remote servers, and then downloads and installs the Chocolatey package manager using a script from a specific URL.
More detail about every command:
Set-ExecutionPolicy Bypass
: Sets PowerShell execution policy to Bypass for the current process-Scope Process
: Only apply to the current PowerShell session-Force
: Supress any confirmation prompt-bor
: Bitwise OR operator3072
: Represents the TSL 1.2 security protocol[System.Net.ServicePointManager]::SecurityProtocol -bor 3072
: Bitwise OR between the current security protocol and TSL 1.2 to allow connection to remote serversiex
: Same as PowerShellInvoke-Expression
to execute a commandNew-Object System.Net.WebClient
: Creates aWebClient
objectDownloadString
: AWebClient
method to download a script from a stringhttps://community.chocolatey.org/install.ps1
: Script to install Chocolatey. You can open this link to review the code.
Reload profile: