20 April 2026

Install PowerShell 7 with automatic update

 Paste this script into administrative PowerShell prompt (version 5 is ok) and it will install newest version of PowerShell with the option to update it using Microsoft Update.

$rel = Invoke-RestMethod 'https://api.github.com/repos/PowerShell/PowerShell/releases/latest'

$url = ($rel.assets | Where-Object name -like 'PowerShell-*-win-x64.msi').browser_download_url

$file = "$env:TEMP\pwsh-latest-x64.msi"

$ProgressPreference = 'SilentlyContinue'

Invoke-WebRequest -Uri $url -OutFile $file

Start-Process msiexec.exe -Wait -ArgumentList "/i `"$file`" /quiet /norestart ADD_PATH=1 USE_MU=1 ENABLE_MU=1"

28 January 2026

Schedule Choco Upgrade

If you are using Chocolatey, you probably want to keep installed software up to date. You can automate it with Task Scheduler (runs as SYSTEM, highest privileges). Run these commands from an elevated Command Prompt / PowerShell.

Always-on machines (weekly schedule):

schtasks /Create /F /RU SYSTEM /RL HIGHEST /SC WEEKLY /D SUN /ST 03:00 /TN "Choco Upgrade" /TR "cmd /V:ON /C echo ==== !DATE! !TIME! ====>> C:\ProgramData\ChocoUpgrade.log & choco upgrade all -y --no-progress >> C:\ProgramData\ChocoUpgrade.log 2>&1"

This works best on machines that are typically powered on at the scheduled time.

Laptops (run on startup, with a 5min delay):

schtasks /Create /F /RU SYSTEM /RL HIGHEST /SC ONSTART /DELAY 0005:00 /TN "Choco Upgrade" /TR "cmd /V:ON /C echo ==== !DATE! !TIME! ====>> C:\ProgramData\ChocoUpgrade.log & choco upgrade all -y --no-progress >> C:\ProgramData\ChocoUpgrade.log 2>&1"

Note: this runs on every startup (Chocolatey will usually finish quickly if there is nothing to upgrade).