Windows Terminal: Run PowerShell as Administrator
*from GitHub: Windows Terminal Issue 691, GitHub: gerardog/gsudo
Currently, Windows Terminal does not support running individual tabs as Administrator.
There is an elegant workaround employing a third-party application, gsudo
.
-
Start PowerShell as Administrator.
- Run:
choco install gsudo -y
Note: you don’t need chocolatey; refer to the gsudo source.
-
Open Windows Terminal ->
Settings
->Add new
- Under
Command line
add this:pwsh.exe -Command "gsudo pwsh"
Note:
pwsh
is for PowerShell 7 (if you have it). This works equally well for the default PowerShell: just replacepwsh
withpowershell
. - Change the tab icon to distinguish it from the non-elevated version.
Here’s a red one.