Get Logon UserName

%3CLINGO-SUB%20id%3D%22lingo-sub-1118165%22%20slang%3D%22en-US%22%3EGet%20Logon%20UserName%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1118165%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20fellow%20humans%2C%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20finding%20how%20to%20get%20logon%20user%20name%20using%20'SYSTEM%20Privilege'%20(NT%20AUTHORITY%5CSYSTEM)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%24currentuser%20%3D%20%24env%3Ausername%0A%24currentuser%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3BCodes%20show%20'SYSTEM'%20value.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHow%20can%20i%20get%20logon%20user%20using%20system%20privilege%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1118165%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EPowerShell%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1118442%22%20slang%3D%22en-US%22%3ERe%3A%20Get%20Logon%20UserName%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1118442%22%20slang%3D%22en-US%22%3E%3CP%3EWhy%20would%20you%20expect%20to%20see%20a%20different%20value%20when%20you%20are%20running%20in%20the%20context%20of%20the%20system%20user%3F%20If%20you%20simply%20want%20to%20list%20all%20users%20currently%20logged%20on%20the%20machine%2C%20use%20one%20of%20the%20methods%20here%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fstackoverflow.com%2Fquestions%2F23219718%2Fpowershell-script-to-see-currently-logged-in-users-domain-and-machine-status%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fstackoverflow.com%2Fquestions%2F23219718%2Fpowershell-script-to-see-currently-logged-in-users-domain-and-machine-status%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1118870%22%20slang%3D%22en-US%22%3ERe%3A%20Get%20Logon%20UserName%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1118870%22%20slang%3D%22en-US%22%3EI%20need%20to%20create%20job%20schedule%20using%20system%20privilege%20on%20AD%20Client.%20(GPO%20Issue)%3CBR%20%2F%3Eso%2C%20I%20should%20to%20except%20user%20privilege.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1124960%22%20slang%3D%22en-US%22%3ERe%3A%20Get%20Logon%20UserName%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1124960%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F525567%22%20target%3D%22_blank%22%3E%40esshin%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20would%20be%20easier%20to%20understand%20if%20you%20could%20share%20more%20detail%20about%20what%20you're%20troubleshooting.%3CBR%20%2F%3EAre%20you%20having%20issues%20with%20a%20client%20applying%20GPO%3F%3CBR%20%2F%3EAre%20you%20trying%20to%20enumerate%20who%20is%20logged%20on%20and%20the%20amount%20of%20priv%20access%20they%20have%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New 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
Highlighted

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...

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

@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?