I wrote gsudo, a sudo for windows that feels like *nix sudo and has a few killer features:
- Run within the current console (attached) without breaking tab-key auto-complete. Or add
-nto launch in a new window. - Handles all scenarios reliably to be used on scripts. (ExitCodes, StdIn/Out/Err Redirection/Capture)
- Supports Cmd/PowerShell/PowerShell Core
- Credentials cache: If
gsudois invoked several times within minutes it only shows the UAC pop-up once.

Usage
gsudo Opens an elevated shell in the current console.
gsudo [options] {command} [arguments]
Executes the specified command with elevated permissions.
Most relevant [options]:
-n | --newStarts the command in a new console with elevated rights (and returns immediately).-w | --waitForce wait for the process to end (and return the exitcode).-s | --systemRun As Local System account ("NT AUTHORITY\SYSTEM").--copyevCopy all environment variables to the elevated session before executing.
Installation
- Using Scoop:
scoop install gsudo - Using Chocolatey:
choco install gsudo - Manual InstallUsing Winget:
winget install gsudo
PowerShell -Command "Set-ExecutionPolicy RemoteSigned -scope Process; iwr -useb https://raw.githubusercontent.com/gerardog/gsudo/master/installgsudo.ps1 | iex"
- Or check the docs and latest release