Support windows terminal to be run with different user credentials. #8748

Closed
opened 2026-01-31 01:36:58 +00:00 by claunia · 16 comments
Owner

Originally created by @AlexisColes on GitHub (Jun 2, 2020).

Description of the new feature/enhancement

It would be a massive plus to have the ability to run Windows Terminal under the security context of a user other than the one logged into windows.

Microsoft recommend "Seperate accounts" for users that need to perform actions that require "privileged access", this means that I have 2 active directory accounts at work.
me@mycomp.com and me.adm@mycomp.com

I log into my computer as me@mycomp.com every day.

A lot of the terminal work that I do day to day involves me launching pwsh as me.adm@mycom.com and running commands from there so that I can have "privileged access" to the required resources.
Try as I might I can not find away of launching windows terminal when logged in as me@mycomp.com under the security context of me.adm@mycomp.com.

This issue is basicly the same as https://github.com/microsoft/terminal/issues/3534 which was closed as it "looks like a /dupe of https://github.com/microsoft/terminal/issues/632". However those 2 issues are clearly not duplicates so thought I would create another one.

Thanks in advance :)

Originally created by @AlexisColes on GitHub (Jun 2, 2020). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> # Description of the new feature/enhancement It would be a massive plus to have the ability to run Windows Terminal under the security context of a user other than the one logged into windows. <!-- A clear and concise description of what the problem is that the new feature would solve. Describe why and how a user would use this new functionality (if applicable). --> Microsoft recommend ["Seperate accounts"](https://docs.microsoft.com/en-us/windows-server/identity/securing-privileged-access/securing-privileged-access) for users that need to perform actions that require "privileged access", this means that I have 2 active directory accounts at work. me@mycomp.com and me.adm@mycomp.com I log into my computer as me@mycomp.com every day. A lot of the terminal work that I do day to day involves me launching pwsh as me.adm@mycom.com and running commands from there so that I can have "privileged access" to the required resources. Try as I might I can not find away of launching windows terminal when logged in as me@mycomp.com under the security context of me.adm@mycomp.com. This issue is basicly the same as [https://github.com/microsoft/terminal/issues/3534](https://github.com/microsoft/terminal/issues/3534) which was closed as it "looks like a /dupe of [https://github.com/microsoft/terminal/issues/632](https://github.com/microsoft/terminal/issues/632)". However those 2 issues are clearly not duplicates so thought I would create another one. Thanks in advance :)
claunia added the Issue-FeatureResolution-Duplicate labels 2026-01-31 01:36:58 +00:00
Author
Owner

@zadjii-msft commented on GitHub (Jun 2, 2020):

You're right, #3534 probably shouldn't be duped to #632. The more correct dupe would be #4217, which is tracking this dependency with the store team.

Thanks!

/dup #4217

@zadjii-msft commented on GitHub (Jun 2, 2020): You're right, #3534 probably shouldn't be duped to #632. The more correct dupe would be #4217, which is tracking this dependency with the store team. Thanks! /dup #4217
Author
Owner

@ghost commented on GitHub (Jun 2, 2020):

Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!

@ghost commented on GitHub (Jun 2, 2020): Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!
Author
Owner

@AlexisColes commented on GitHub (Jun 2, 2020):

That does indeed look like a better dupe, thanks @zadjii-msft will follow that one.

@AlexisColes commented on GitHub (Jun 2, 2020): That does indeed look like a better dupe, thanks @zadjii-msft will follow that one.
Author
Owner

@yllekz commented on GitHub (Jun 2, 2020):

FYI, I found a workaround for this by running the application as-is, and then just modifying the JSON config file to include entries to spawn powershell sessions as another user.

Note that this will not get the new session to run a new tab, rather, it will launch a new window. It DOES work however as available drop-down options. Would be nice to see this baked into the application where instead of opening a new window, it will just open in-place as a new tab instead.

Add new entry(ies) to your settings.json file, in the vein of the below examples:

        {
            // "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
            "name": "PowerShell 7 (Privileged account)",
            "commandline": "C:\\Windows\\System32\\runas.exe /savecred /user:domain\\my_privilegedacct \"C:\\Program Files\\PowerShell\\7\\pwsh.exe\"",
            "hidden": false
        },
        {
            // "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
            "name": "Windows PowerShell (Privileged account)",
            "commandline": "C:\\Windows\\System32\\runas.exe /savecred /user:domain\\my_privilegedacct powershell",
            "hidden": false
        },
        //other entries etc as you see fit
@yllekz commented on GitHub (Jun 2, 2020): FYI, I found a workaround for this by running the application as-is, and then just modifying the JSON config file to include entries to spawn powershell sessions as another user. Note that this will not get the new session to run a new tab, rather, it will launch a new window. It DOES work however as available drop-down options. Would be nice to see this baked into the application where instead of opening a new window, it will just open in-place as a new tab instead. Add new entry(ies) to your settings.json file, in the vein of the below examples: ``` { // "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}", "name": "PowerShell 7 (Privileged account)", "commandline": "C:\\Windows\\System32\\runas.exe /savecred /user:domain\\my_privilegedacct \"C:\\Program Files\\PowerShell\\7\\pwsh.exe\"", "hidden": false }, { // "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}", "name": "Windows PowerShell (Privileged account)", "commandline": "C:\\Windows\\System32\\runas.exe /savecred /user:domain\\my_privilegedacct powershell", "hidden": false }, //other entries etc as you see fit ```
Author
Owner

@Clifra-Jones commented on GitHub (Aug 7, 2020):

FYI, I found a workaround for this by running the application as-is, and then just modifying the JSON config file to include entries to spawn powershell sessions as another user.

Note that this will not get the new session to run a new tab, rather, it will launch a new window. It DOES work however as available drop-down options. Would be nice to see this baked into the application where instead of opening a new window, it will just open in-place as a new tab instead.

Add new entry(ies) to your settings.json file, in the vein of the below examples:

        {
            // "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
            "name": "PowerShell 7 (Privileged account)",
            "commandline": "C:\\Windows\\System32\\runas.exe /savecred /user:domain\\my_privilegedacct \"C:\\Program Files\\PowerShell\\7\\pwsh.exe\"",
            "hidden": false
        },
        {
            // "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
            "name": "Windows PowerShell (Privileged account)",
            "commandline": "C:\\Windows\\System32\\runas.exe /savecred /user:domain\\my_privilegedacct powershell",
            "hidden": false
        },
        //other entries etc as you see fit

This works but it really is not an answer. Why bother opening Windows Terminal if I am just getting a new command window when I need to operate as my Admin account.

As of now,, Windows Terminal is just not useful for administering Windows systems with Powrshell.

@Clifra-Jones commented on GitHub (Aug 7, 2020): > FYI, I found a workaround for this by running the application as-is, and then just modifying the JSON config file to include entries to spawn powershell sessions as another user. > > Note that this will not get the new session to run a new tab, rather, it will launch a new window. It DOES work however as available drop-down options. Would be nice to see this baked into the application where instead of opening a new window, it will just open in-place as a new tab instead. > > Add new entry(ies) to your settings.json file, in the vein of the below examples: > > ``` > { > // "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}", > "name": "PowerShell 7 (Privileged account)", > "commandline": "C:\\Windows\\System32\\runas.exe /savecred /user:domain\\my_privilegedacct \"C:\\Program Files\\PowerShell\\7\\pwsh.exe\"", > "hidden": false > }, > { > // "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}", > "name": "Windows PowerShell (Privileged account)", > "commandline": "C:\\Windows\\System32\\runas.exe /savecred /user:domain\\my_privilegedacct powershell", > "hidden": false > }, > //other entries etc as you see fit > ``` This works but it really is not an answer. Why bother opening Windows Terminal if I am just getting a new command window when I need to operate as my Admin account. As of now,, Windows Terminal is just not useful for administering Windows systems with Powrshell.
Author
Owner

@scotpower commented on GitHub (Sep 2, 2020):

Grant users full control access to the application folder, and you are good to go. Note: the system account (e.g. psexec -s ) is required to modify the ACLs, and you'll have to make the change after each update. I wrote a simple script to do this for me, and created a couple desktop icons I can easily update/right-click-RunAs when needed. It grabs the logged on user account, but can be tweaked use whatever account name you like.

@echo off & pushd %~dp0
if not "%username%" == "%computername%$" echo This script must be run with the system account! & goto:eof
echo ++ Configuring permissions for Windows Terminal
for /f "tokens=1,2,*" %%a in ('tasklist /FI "IMAGENAME eq explorer.exe" /FO LIST /V') do if /i "%%a %%b"=="User Name:" set _loggedOnUser=%%c
echo ++ Resetting ACLs for username: [%_loggedOnUser%]
echo ++ Getting latest application folder and exe paths...
set _winAppsDir=%ProgramFiles%\WindowsApps
:: Update folder version number when needed
for /f "tokens=*" %%i in ('dir "%_winAppsDir%\Microsoft.WindowsTerminal_1*" /on /b') do set _winTermDir=%_winAppsDir%\%%i
set _winTermExe="%_winTermDir%\WindowsTerminal.exe"
echo ++ Windows Terminal Directory: [%_winTermDir%]
echo ++ Setting permissions...
icacls "%_winTermDir%" /grant %_loggedOnUser%:(OI)(CI)(F) /T
echo ++ Path to executable: [%_winTermExe%]
popd
:eof

@scotpower commented on GitHub (Sep 2, 2020): Grant users full control access to the application folder, and you are good to go. Note: the system account (e.g. psexec -s ) is required to modify the ACLs, and you'll have to make the change after each update. I wrote a simple script to do this for me, and created a couple desktop icons I can easily update/right-click-RunAs when needed. It grabs the logged on user account, but can be tweaked use whatever account name you like. `@echo off & pushd %~dp0` ` if not "%username%" == "%computername%$" echo This script must be run with the system account! & goto:eof` ` echo ++ Configuring permissions for Windows Terminal` ` for /f "tokens=1,2,*" %%a in ('tasklist /FI "IMAGENAME eq explorer.exe" /FO LIST /V') do if /i "%%a %%b"=="User Name:" set _loggedOnUser=%%c` ` echo ++ Resetting ACLs for username: [%_loggedOnUser%]` ` echo ++ Getting latest application folder and exe paths...` ` set _winAppsDir=%ProgramFiles%\WindowsApps` ` :: Update folder version number when needed` ` for /f "tokens=*" %%i in ('dir "%_winAppsDir%\Microsoft.WindowsTerminal_1*" /on /b') do set _winTermDir=%_winAppsDir%\%%i` ` set _winTermExe="%_winTermDir%\WindowsTerminal.exe"` ` echo ++ Windows Terminal Directory: [%_winTermDir%]` ` echo ++ Setting permissions...` ` icacls "%_winTermDir%" /grant %_loggedOnUser%:(OI)(CI)(F) /T` ` echo ++ Path to executable: [%_winTermExe%]` `popd` `:eof`
Author
Owner

@DHowett commented on GitHub (Sep 3, 2020):

If you're going to mess with the permissions in system folders, you would be much better off just extracting the msixbundle like a zip file and using WindowsTerminal.exe directly. It'll be much less of a headache and runs less risk of making the application installation service upset with you.

@DHowett commented on GitHub (Sep 3, 2020): If you're going to mess with the permissions in system folders, you would be *much* better off just extracting the msixbundle like a zip file and using WindowsTerminal.exe directly. It'll be much less of a headache and runs less risk of making the application installation service upset with you.
Author
Owner

@Wardrop commented on GitHub (Sep 28, 2022):

As a workaround for the time being, for those wanting a powershell window as another user, I use the following:

%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe -Command "enter-pssession -credential (Get-Credential """$env:username.admin""") -computername """localhost""""

In our environment we use a ".admin" suffix so I append that to the current username, but that can obviously be changed to whatever.

This requires the "Run this profile as Administrator" to be checked for the profile, and because of that, if you don't want it to open in a new terminal window, make sure you're default profile is also set to "Run this profile as Administrator". Windows terminal doesn't allow you to mix elevated and non-elevated profile/terminals in the same window. There's a little shield icon that shows in the top-left of the terminal window to indicate whether it's an elevated window or not.

image
@Wardrop commented on GitHub (Sep 28, 2022): As a workaround for the time being, for those wanting a powershell window as another user, I use the following: `%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe -Command "enter-pssession -credential (Get-Credential """$env:username.admin""") -computername """localhost""""` In our environment we use a ".admin" suffix so I append that to the current username, but that can obviously be changed to whatever. This requires the "Run this profile as Administrator" to be checked for the profile, and because of that, if you don't want it to open in a new terminal window, make sure you're default profile is also set to "Run this profile as Administrator". Windows terminal doesn't allow you to mix elevated and non-elevated profile/terminals in the same window. There's a little shield icon that shows in the top-left of the terminal window to indicate whether it's an elevated window or not. <img width="867" alt="image" src="https://user-images.githubusercontent.com/201442/192689354-941cfca1-5aee-4a0c-9f9e-fb3bff08d557.png">
Author
Owner

@Wardrop commented on GitHub (Nov 7, 2022):

I forget to add "-NoExit" to the above command example. Should be:

%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe -NoExit -Command "enter-pssession -credential (Get-Credential """$env:username.admin""") -computername """localhost""""

Also you'll run into credential double-hop issues so accessing network resources may be a problem. Native support for this is definitely a needed feature.

@Wardrop commented on GitHub (Nov 7, 2022): I forget to add "-NoExit" to the above command example. Should be: ``` %SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe -NoExit -Command "enter-pssession -credential (Get-Credential """$env:username.admin""") -computername """localhost"""" ``` Also you'll run into credential double-hop issues so accessing network resources may be a problem. Native support for this is definitely a needed feature.
Author
Owner

@jwoodard80 commented on GitHub (Mar 29, 2023):

I am in the identical situation as the original poster with normal/admin accounts at work and would love to see this as well. This would certainly make my day-to-day much easier.

@jwoodard80 commented on GitHub (Mar 29, 2023): I am in the identical situation as the original poster with normal/admin accounts at work and would love to see this as well. This would certainly make my day-to-day much easier.
Author
Owner

@RickoT commented on GitHub (Apr 21, 2023):

I also wanted to chime in on this. Having the terminal application be more like a built in for all users instead of user based would be a huge plus. We remote into multiple machines to assist users, not being able to launch terminal as a user that's never logged into a machine before would be fantastic, but given the state of terminal, it's basically useless for our purposes which is sad because I really love terminal

@RickoT commented on GitHub (Apr 21, 2023): I also wanted to chime in on this. Having the terminal application be more like a built in for all users instead of user based would be a huge plus. We remote into multiple machines to assist users, not being able to launch terminal as a user that's never logged into a machine before would be fantastic, but given the state of terminal, it's basically useless for our purposes which is sad because I really love terminal
Author
Owner

@zadjii-msft commented on GitHub (Apr 21, 2023):

I mean, as of Windows 11, it is a built-in app for all users 😉

@zadjii-msft commented on GitHub (Apr 21, 2023): I mean, as of Windows 11, it _is_ a built-in app for all users 😉
Author
Owner

@RickoT commented on GitHub (Apr 21, 2023):

Yeah but I mean built into the OS like powershell or CMD... problem is that we don't log into machines directly, we remote in to support users and they are (typically) logged in on their profile. You can't elevate applications that don't exist for your user, so if you elevate terminal, and you've never logged into the workstation, it technically doesn't exist for your elevated user.

I hope that makes sense.

@RickoT commented on GitHub (Apr 21, 2023): Yeah but I mean built into the OS like powershell or CMD... problem is that we don't log into machines directly, we remote in to support users and they are (typically) logged in on their profile. You can't elevate applications that don't exist for your user, so if you elevate terminal, and you've never logged into the workstation, it technically doesn't exist for your elevated user. I hope that makes sense.
Author
Owner

@tag8563 commented on GitHub (Feb 1, 2024):

I forget to add "-NoExit" to the above command example. Should be:

%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe -NoExit -Command "enter-pssession -credential (Get-Credential """$env:username.admin""") -computername """localhost""""

Also you'll run into credential double-hop issues so accessing network resources may be a problem. Native support for this is definitely a needed feature.

slight tweak

"C:\Program Files\PowerShell\7\pwsh.exe" -NoExit -Command "enter-pssession -credential (Get-Credential -username domain\admine_account) -computername """localhost"""

the triple quotes cuased it to throw a fit

@tag8563 commented on GitHub (Feb 1, 2024): > I forget to add "-NoExit" to the above command example. Should be: > > ``` > %SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe -NoExit -Command "enter-pssession -credential (Get-Credential """$env:username.admin""") -computername """localhost"""" > ``` > > Also you'll run into credential double-hop issues so accessing network resources may be a problem. Native support for this is definitely a needed feature. slight tweak `"C:\Program Files\PowerShell\7\pwsh.exe" -NoExit -Command "enter-pssession -credential (Get-Credential -username domain\admine_account) -computername """localhost""" ` the triple quotes cuased it to throw a fit
Author
Owner

@aa-ferret-aa commented on GitHub (Jul 27, 2025):

I mean, as of Windows 11, it is a built-in app for all users 😉
True however you cannot RunAs a different account. Microsoft pushes separating privileges which makes sense - but then removes the ability to elevate the very tools we need to administrate the machines / environment (AD).
I understand the Microsoft is pushing the cloud but in the real world we still have to deal with AD environments and real desktop computers. MS and its developers needs to realise that the cloud is not everything the rest of us still live a real world not a pure cloud environment.

@aa-ferret-aa commented on GitHub (Jul 27, 2025): > I mean, as of Windows 11, it _is_ a built-in app for all users 😉 True however you cannot RunAs a different account. Microsoft pushes separating privileges which makes sense - but then removes the ability to elevate the very tools we need to administrate the machines / environment (AD). I understand the Microsoft is pushing the cloud but in the real world we still have to deal with AD environments and real desktop computers. MS and its developers needs to realise that the cloud is not everything the rest of us still live a real world not a pure cloud environment.
Author
Owner

@CHaNNeL-NiNe commented on GitHub (Dec 2, 2025):

as a workaround, runas /user:username "pwsh -command wt"

@CHaNNeL-NiNe commented on GitHub (Dec 2, 2025): as a workaround, runas /user:username "pwsh -command wt"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#8748