I've used win32_loggedonuser, but ran into an issue where more than one domain user was returned, so it didn't work for my purposes. Instead I used (In powershell)
#Get Currently logged in user
$ExplorerProcess = gwmi win32_process | where name -Match explorer
if($ExplorerProcess.getowner().user.count -gt 1){
$LoggedOnUser = $ExplorerProcess.getowner().user[0]
}
else{
$LoggedOnUser = $ExplorerProcess.getowner().user
}
the if is because sometimes getowner will report more than one user for some reason, don't know why but in my case it was the same user so it wasn't an issue.