How to Run PowerShell as an Administrator from a Windows Terminal?

Administrator tabs cannot ordinarily be open at the same time as non-elevated tabs in the Windows Terminal. It is, however, achievable with the use of a third-party tool! Here’s how to use Windows Terminal to run PowerShell as an administrator.

How does Windows Terminal Handle Administrative Permissions?

Running PowerShell as an administrator (also known as elevated PowerShell) gives you access to files and tasks that are ordinarily forbidden. Restricted commands and files are usually crucial to the operating system’s functionality and security, and thus require specific administrative permissions to run, move, change, or delete them.

For security concerns, you can’t have mixed-permission PowerShell tabs open in Windows Terminal. Because it’s difficult to entirely isolate the open tabs, something running in a non-elevated PowerShell tab may theoretically raise its permissions through an elevated PowerShell tab, leaving your PC vulnerable. The developers felt that even if the risk was minor, it was best to avoid it altogether.

How to Start PowerShell as Admin In Windows Terminal?

Because Windows Terminal doesn’t support mixed-permissions tabs, the only method to execute PowerShell as an administrator within Windows Terminal is to start Windows Terminal as administrator. When you run Windows Terminal as administrator, all new tabs you open will be operated as administrator as well.

To start Windows Terminal as an administrator, go to Start, put “terminal” into the search box, and then expand the list of alternatives by clicking the chevron (it looks like an arrow without the tail).

Click the chevron

In the expanded list, select “Run as administrator.”

Click "Run as Administrator."

How to Use Third-Party Tools to Run PowerShell as an Administrator in Windows Terminal
For security reasons, Windows Terminal does not allow you to mix elevated and non-elevated PowerShell tabs. If you still want to do it, you can use a little open-source application called gsudo to allow it.

Winget is used to install Gsudo from the command line. To install Gerardog.gsudoin, open PowerShell and execute winget install gerardog.gsudoin.

Winget install gerardog.sudo in PowerShell

The installation will start right away; when requested to accept the terms and conditions, press y, then Enter. If everything goes well, you’ll see something like this:

Successful install of gsudo

You must open Windows Terminal and establish a new profile after installing gsudo. Select “Settings” from the chevron at the top of Windows Terminal.

Click the chevron, then click "Settings."

“Add a New Profile,” “Windows PowerShell,” and “Duplicate” are the options.

Click "Add A New Profile," then select Windows PowerShell, then click "Duplicate."

A few lines in this profile need to be changed.

To avoid confusion with the non-admin PowerShell profile, rename the duplicated profile to something meaningful, such as “PowerShell (Administrator).”

We’ll also have to change the command that runs when this profile is activated. Click the “Command Line” line, type gsudo powershell.exe, and then click the “Save” button in the bottom right corner.

Change the name, then change the command line, then click "Save."

By selecting the PowerShell (Administrator) profile from the chevron near the top of any Windows Terminal, you can open the new elevated PowerShell.

Click "Powershell(Administrator)"

That’s it; you may now use the same terminal to run both admin and non-admin PowerShell windows. If you want, you may use the same procedure with Command Prompt by changing the command line to gsudo cmd instead of gsudo powershell.

Leave a Comment

Your email address will not be published. Required fields are marked *