Skip to content

Instantly share code, notes, and snippets.

@kfchou
Last active August 28, 2024 00:08
Show Gist options
  • Select an option

  • Save kfchou/73d8d2d2050804cbd336fc3c35bd0be6 to your computer and use it in GitHub Desktop.

Select an option

Save kfchou/73d8d2d2050804cbd336fc3c35bd0be6 to your computer and use it in GitHub Desktop.
New Windows Machine Setup
# PowerShell Script to Install Chocolatey and Common Packages
# Ensure running as Administrator
if (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
{
Write-Warning "You need to have Administrator rights to run this script."
exit
}
# Set execution policy to allow the script to run
Set-ExecutionPolicy Bypass -Scope Process -Force
# Install Chocolatey
Write-Host "Installing Chocolatey..."
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'))
# Refresh environment variables
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine")
# Install common packages
$packages = @(
"googlechrome",
"wsl2",
"git",
"7zip",
"vscode",
"nodejs",
"zoom",
"vlc",
"ccleaner",
"slack",
"dropbox",
)
Write-Host "Installing packages: $($packages -join ', ')"
choco install $packages -y
# Confirm installation
Write-Host "Installation complete. Installed packages:"
choco list --local-only
# Optionally, restart to apply changes
Write-Host "It is recommended to restart your computer to apply all changes."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment