PowerShell – SCCM – Return Current User

email me

Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI -Name LastLoggedOnUser | select -ExpandProperty LastLoggedOnUser
(Get-WmiObject -Class Win32_Process -Filter "Name = 'explorer.exe'").GetOwner() | select -ExpandProperty User

 

Notes

Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI -Name LastLoggedOnUser | select -ExpandProperty LastLoggedOnUser

(Get-WmiObject -Class Win32_Process -Filter “Name = ‘explorer.exe'”).GetOwner() | select -ExpandProperty User

 

tags: Return current user, MrNetTek