mabdelhamid
Enthusiast
Enthusiast

Windows 10, retrieve logged in user

Hello,

Is there a way to retrieve current Windows 10 logged in user (Not the enrollment user), Windows 10 Devices are shared between employees and we need to tell who is currently logged to the device.

 

Thanks in advance

Labels (1)
Tags (1)
0 Kudos
4 Replies
ogushia
Enthusiast
Enthusiast

We had the same requirements before, and I was able to get the logged-in user using a sensor like the one below.

$ActiveSession = (quser | Where-Object {$_ -match 'Active'}).Remove(0, 1)
$ActiveUser = ($ActiveSession -split ' +')[0]
write-output $ActiveUser

0 Kudos
RoderikdeBlock
Enthusiast
Enthusiast

Or 

$User = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name

Write-Output $User

Roderik de Block


Blog: https://roderikdeblock.com
0 Kudos
mabdelhamid
Enthusiast
Enthusiast

Thanks all, the deployment is on-prem, Sensor is not available.

0 Kudos
edgarastrov
Contributor
Contributor

Is there a way to push it to console so it can be seen from CN rather than intelligence reports?

0 Kudos