Forum Discussion
$env:Username Different Outputs
Hi
$Env:Username is a dynamic variable set when the user login, you can also check the value for this variable from CMD by typing %Username%
What might come to my mind is there is an impersonation when, such as a process runas, or Powershell executed under another credential
- SchulziSep 29, 2020Brass Contributor
Hi farismalaeb
I just noticed that myself...
I startet 2 Windows of PS now!
1. startet via "WIn+R -> pwsh -> CTRL+SHIFT+Return(Starts it as admin)"
(cat is our local Domain Admin)
2. startet via Startmenu (Powershell -> Run as Administrator)
Startet in "System32"
So why does Powershell start with different credentials?
And how can I "say" which credential to choose?
Greetings
Yannik
- farismalaebSep 29, 2020Steel Contributor
This is normal behavior, as PowerShell which "Run as Administrator" will start in the system32 directory, as it already has the access to it "it ran as admin"
but running PowerShell normally will make PowerShell set the path to the user home directory as its the path it has access to, and it doesn't have full control over the system32 folder.
the username used is the same
- SchulziOct 02, 2020Brass Contributor
That does not answer my question...
My Question still is "Why does Powershell launch in different Identities?"
For my point of view (and the one of my colleague) it's happening random, without a obvious reason...
We can launch Powershell on 2 different systems ON THE SAME WAY and on one PC it launches under "User" and the other one launches under "system32".
Nothing done different, but still got different results...
Greeting
Yannik Schulz