Skip to content

Instantly share code, notes, and snippets.

@mpern
Created December 30, 2020 08:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mpern/ae90b5841fd6a33307a4f12ea40e48be to your computer and use it in GitHub Desktop.
Save mpern/ae90b5841fd6a33307a4f12ea40e48be to your computer and use it in GitHub Desktop.
`choco upgrade` with auto-elevation (automatically run as Administrator)
if (-not (([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator))) {
Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`" `"$args`"" -Verb RunAs; exit
}
choco upgrade all -y;
Write-Host "`n`nPress any key to exit script..."; $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") > $null;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment