Windows Terminal: Run PowerShell as Administrator
This post is from 2021 and may be out of date. Windows Terminal now supports this natively (Run this profile as Administrator in the profile settings), and Windows 11 24H2 has a built-in
sudo.
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:
1
choco install gsudo -y
Note: you don’t need chocolatey; refer to the gsudo source.
Open Windows Terminal ->
Settings->Add new- Under
Command lineadd this:1
pwsh.exe -Command "gsudo pwsh"
Note:
pwshis for PowerShell 7 (if you have it). This works equally well for the default PowerShell: just replacepwshwithpowershell. - Change the tab icon to distinguish it from the non-elevated version.
Here’s a red one.
This post is licensed under CC BY 4.0 by the author.