microsoft / microsoft/terminal

RunAs Administrator returning "SYSTEM" as $env:USERNAME in PowerShell

Open
#16,200 17 comments 4 reactions 1 assignee Claimed by @lhecker View on GitHub
Area-TerminalConnection Issue-Bug Priority-2 Product-Terminal
Dominant language
C++
Stars
105k
Forks
9.6k
Avg merge
3d 17h
Merged PRs (30d)
29

Description

### 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:
```powershell
$env:USERNAME
```

### Expected Behavior

The username of the currently logged in user should be returned

### Actual Behavior

`SYSTEM` is returned

The 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).
![image](https://github.com/microsoft/terminal/assets/7157790/5ef3961f-12c0-48d0-ba64-bdc4f7114657)

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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.