Skip to content

Instantly share code, notes, and snippets.

@ScriptAutomate
Last active January 3, 2024 15:27
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ScriptAutomate/02e0cf33786f869740ee963ed6a913c1 to your computer and use it in GitHub Desktop.
Save ScriptAutomate/02e0cf33786f869740ee963ed6a913c1 to your computer and use it in GitHub Desktop.
Install Chocolatey on Windows 10 or 11 via PowerShell w/ Some Starter Packages
<#
Simple, nice bootstrap to get Windows 10 up-and-running with nice setup!
- Installs chocolatey (choco)
- Installs common software
I highly recommend Windows Subsystem for Linux (WSL), also, which is covered in
a separate gist. It also has a choco command for installing Docker Desktop after:
- https://gist.github.com/ScriptAutomate/f94cd44dacd0f420fae65414e717212d
#>
## IN AN ELEVATED SHELL
## Right-click PowerShell -> Run As Administrator
# Install chocolatey
## For more info on chocolatey, see: https://chocolatey.org/docs/getting-started
## For more info on this install approach: https://chocolatey.org/install#individual
###
# WARNING: As said by Chocolatey, themselves:
# "Please inspect https://chocolatey.org/install.ps1 prior to running any of these scripts
# to ensure safety. We already know it's safe, but you should verify the security and contents
# of any script from the internet you are not familiar with. All of these scripts download a
# remote PowerShell script and execute it on your machine. We take security very seriously."
# Learn more about Chocolatey security protocols: https://docs.chocolatey.org/en-us/information/security
###
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'))
### Install things with chocolatey!
## Search from terminal: choco search <package>
## View locally installed choco packages: choco list --local-only
## Search visually on site: https://chocolatey.org/packages
## I like installing the below packages, for example
# Windows Terminal: Huge improvement over native tooling
choco install microsoft-windows-terminal -y
# PowerShell Core: Latest PowerShell, can sit ontop of Windows PowerShell
## run with pwsh.exe or in Microsoft Terminal when installed
choco install powershell-core -y
# Visual Studio Code: Cross-platform IDE of choice for me
choco install vscode -y
# Git: Should be hard to avoid needing this at work
choco install git -y
# Google Chrome
choco install googlechrome -y
# Brave Browser: Alternative web browser with many fans
choco install brave -y
@ScriptAutomate
Copy link
Author

ScriptAutomate commented Aug 22, 2020

I'll be testing the following for downloading the choco installer as a potential update to this base script:

https://gist.github.com/ScriptAutomate/02e0cf33786f869740ee963ed6a913c1#file-install-chocostarterpackages-ps1-L18-L20

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'))

Where an updated version may look like this:

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

@ScriptAutomate
Copy link
Author

ScriptAutomate commented May 6, 2021

Applied an update/comment to the script about explicitly verifying the contents of code that is being remotely accessed and downloaded. From Chocolatey's site in the installation page:

NOTE: Please inspect https://chocolatey.org/install.ps1 prior to running any of these scripts to ensure safety. We already know it's safe, but you should verify the security and contents of any script from the internet you are not familiar with. All of these scripts download a remote PowerShell script and execute it on your machine. We take security very seriously. Learn more about our security protocols.

I added this information in part by the Codecov breach and modification of their downloadable bash script, which results in pipelines across the world having their environment variable potentially harvested:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment