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


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:

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


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?