Situatie
The Windows Terminal won’t normally allow administrator tabs to be open simultaneously with other non-elevated tabs. But with a third-party tool, it is possible! Here’s how to launch PowerShell as Admin in Windows Terminal.
Solutie
How Windows Terminal Handles Administrative Permissions
Running PowerShell as admin (otherwise known as an elevated PowerShell), allows you to run commands and access files that are normally restricted. The commands and files that are restricted tend to be critical to the functioning and security of the operating system, and they require special administrative permissions to run, move, modify, or delete.
Windows Terminal doesn’t allow you to have mixed-permission PowerShell tabs open for security reasons. It is difficult to fully isolate the opens tabs from each other — in practice, that means something running in a non-elevated PowerShell tab could conceivably escalate its permissions through an elevated PowerShell tab, leaving your PC exposed. The developers decided that risk — though small — was best avoided entirely.
How to Start PowerShell as Admin In Windows Terminal
Since Windows Terminal doesn’t allow mixed-permissions tabs natively, there is only one way to run PowerShell as Admin within Windows Terminal — by running Windows Terminal as administrator. When Windows Terminal is run as administrator, all new tabs opened will also be run as administrator.
To run Windows Terminal as administrator, click Start, type “terminal” into the search bar, then click the chevron (it looks like an arrow without the tail) to expand the list of options.
Click “Run as administrator” in the expanded list.
Tip: You can also right-click the Windows Terminal shortcut after searching for it and select “Run as Administrator.”
How to Start PowerShell as Admin in Windows Terminal with Third-Party Tools
Windows Terminal doesn’t support mixing elevated and non-elevated PowerShell tabs for security reasons. If you’d like to do it anyway, you can enable it with a small open-source program called gsudo.
Gsudo is installed by command-line using winget. Launch PowerShell, type winget install gerardog.gsudo
in, and then hit Enter.
The installation will begin immediately; when prompted to accept the terms and conditions, hit the y
key, and then hit Enter. If it completes successfully, you’ll see something like this:
Once gsudo has been installed, you need to open Windows Terminal and create a new profile. Click the chevron at the top of Windows Terminal, and then click “Settings.”
Click “Add a New Profile,” select “Windows PowerShell,” and then click “Duplicate.”
We need to modify a few lines on this profile.
First, you should rename the duplicated profile something descriptive, like “PowerShell (Administrator),” so it doesn’t get mixed up with the non-admin PowerShell profile.
We also need to modify the command that is executed when this profile is activated. Click the line labeled “Command Line,” type gsudo powershell.exe
, and then click “Save” in the bottom right.
You can launch the new elevated PowerShell in any Windows Terminal by clicking the chevron near the top and selecting the PowerShell (Administrator) profile.
That’s it — you can now have both admin and non-admin PowerShell windows open in the same terminal. If you’d like, the exact same process works for Command Prompt as well, except the command line is changed to gsudo cmd
instead of gsudo powershell
.
Leave A Comment?