Get Logon UserName

Copper Contributor

Hello fellow humans, 

 

I'm finding how to get logon user name using 'SYSTEM Privilege' (NT AUTHORITY\SYSTEM)

 

 

$currentuser = $env:username
$currentuser

 

Codes show 'SYSTEM' value.

 

How can i get logon user using system privilege?

 

Kind Regards

 

3 Replies

Why would you expect to see a different value when you are running in the context of the system user? If you simply want to list all users currently logged on the machine, use one of the methods here: https://stackoverflow.com/questions/23219718/powershell-script-to-see-currently-logged-in-users-doma...

I need to create job schedule using system privilege on AD Client. (GPO Issue)
so, I should to except user privilege.

@esshin 

This would be easier to understand if you could share more detail about what you're troubleshooting.
Are you having issues with a client applying GPO?
Are you trying to enumerate who is logged on and the amount of priv access they have?