Sep 28 2020 01:49 AM - edited Sep 28 2020 01:58 AM
Hello,
I have a little Question/Problem using Powershell...
I got 2 Different PC running Windows-Powershell as Admin (both with same Domain-Account (example: cat40050))
BUT i get 2 Different Outputs...
On PC1 I get the current User that is logged on the System(example: T40050)
On PC2 I get the Admin shown that is running Windows-PS...(example: cat40050)
I noticed that one PS-Window is running as "user" and one in "system32"
Both startet from "C:\Windows\System32\WindowsPowerShell\v1.0\"
Why is it like that?
And is there a way to say "only use current logged on user" or start in/as C:\Users\T40...?
T4.... Users are normal Users with no Adminprivileges
cat4... Users are our local Admins (via Domain)
Greetings
Yannik Schulz
Sep 28 2020 02:26 AM
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
Sep 29 2020 03:19 AM
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
Sep 29 2020 04:38 AM
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
Oct 02 2020 04:58 AM
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
Nov 04 2020 02:20 AM
Quick Update what I want to do:
Launching Powershell as an Admin but still stay in the Current User (T4....-User) and not as the Admin User (cat....)
The "T-Users" dont have Admin-privileges the "Cat-Users" have...
BUT in need to stay logged on as the "T-User" in the new PS-Session/Windows that my script will work properly to edit all information in the "T-User-Profile".
Greetings
Yannik Schulz