-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RunAs Administrator returning "SYSTEM" as $env:USERNAME in PowerShell #16200
Comments
I learned something about the |
Do you use "over-the-shoulder" elevation (where you need to provide an admin username and password which is different from your main user)? |
This comment was marked as resolved.
This comment was marked as resolved.
@DHowett - I'm leveraging Win+X, A - which triggers UAC. At that prompt, I'm providing a credential that is different than my logged in user.
@237dmitry - Terminal version 1.19.2682.0? Leave it to me to have the weird issue. |
So, I think it might be because of this. "Over-the-shoulder" elevation is slightly different from the normal split-token kind of elevation that most folks use. If you launch PowerShell directly as admin, without terminal (Win+R, |
This comment was marked as resolved.
This comment was marked as resolved.
@DHowett - No. This is what my screenshot is demonstrating (left side is launching PowerShell outside of Terminal). This issue only occurs when Terminal is in play. |
Whoops, I'm sorry about that. Shows how well I pay attention. This may be a side effect of us regenerating the user environment block from first principles rather than inheriting it from Explorer. Hmm. |
No worries! I'm sure you see a million of these issues a day. I'm happy to do whatever testing is required. |
Note to self: I probably accidentally fixed this in #16190 and I just need to fix the incorrect comment here: Lines 435 to 437 in 64b5b28
|
@lhecker |
I had the same issue when Windows Terminal with PowerShell was elevated via UAC, and to evade it, I changed |
The
Lines 445 to 475 in 4a243f0
Also, some variables from a normal logon session are missing in the OTS case, such as |
We have a somewhat connected issue (I let you judge if this belongs here if not I will open a separate issue). SystemOr computers have The faultLet us assume the useris
Expected Behaviour
I am human
|
Windows Terminal version
1.19.2682.0
Windows build number
10.0.22621.0
Other Software
Windows PowerShell 5.1.22621.2428
PowerShell 7.3.8
Steps to reproduce
Launch Terminal as Administrator (Win+X, A)
Issue the following:
$env:USERNAME
Expected Behavior
The username of the currently logged in user should be returned
Actual Behavior
SYSTEM
is returnedThe screenshot included shows PWSH 7.3.8 running outside Terminal (top left) and inside Terminal (top right) and Windows PowerShell 5.1 running outside Terminal (bottom left) and inside Terminal (bottom right).
The output of
$env:USERNAME
(which is the expected output) has been redacted in the screenshots and the prompt customized to prevent data leak - but this occurs with no customizations and with a fresh installation of Terminal from the Windows Store.The text was updated successfully, but these errors were encountered: