sudo / elevate on Windows 11

August 1, 2021 1 By addshore

Windows has never had a native sudo or elevation feature.

Of course if you write the correct Power Shell commands you can make this happen, but what we really want is convenience.

There are various packages around to help out and various ways to install them.

And in Windows 11 with a new package manager, installing one of them as never been so easy.

gsudo

gsudo is a sudo equivalent for Windows, with a similar user-experience as the original *nix sudo.

It can easily be installed using Scoop, Chocolatey, WinGet or manually.

My recommendation for Windows 11 would be to use the new package manager, winget!

winget install gsudo

You won’t be able to use gsudo right away, as it won’t be in your path. TO fix this run the below command if you are in powershell (otherwise maybe just open a fresh shell).

$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") 
Code language: PHP (php)

After this you can open an elevated shell using gsudo, or run another elevated command.

gsudo echo fooCode language: PHP (php)

You’ll get a small User Account Control popup you need to confirm

elevate

Previously on Windows 10 I have used the elevate command installed from chocolatey.

Choose whichever looks best to you!