Quantcast
Channel: PowerShell
Viewing all articles
Browse latest Browse all 15370

Powershell: Getting current logged on user

$
0
0

Ok, this is a little more difficult than the title makes it out to be.

I know $env:username will get me the user.

Unfortunately, that's not the user I want to get when I'm in an elevated ps window.

Basically I am using a logon script that starts a powershell process as another user.

Now here's the two questions I have:

1. Can I get the username prior to starting the elevated prompt and pass it to the elevated prompt? If so how?

2. Once in the elevated prompt, can I some how pull the user that logged on rather than who the user is in the elevated prompt? Again, if so, how?


Viewing all articles
Browse latest Browse all 15370

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>