question

dilannanayakkara-8008 avatar image
0 Votes"
dilannanayakkara-8008 asked Crystal-MSFT commented

Find out last logon user of MDM assigned Coporate Device

Hi All,

I want to change my current primary owner of the MDM assigned device to last logon user. In my case we have Intune administrator as a primary user for all the MDM devices and first I want to find out last logon user of each device and then change the primary user to last logon user.

so I would expect the help to achieve the below task.

1) Find out last logon user name of each MDM corporate device.

Thanks,
Dilan

mem-intune-generalmem-intune-device-configurations
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Crystal-MSFT avatar image
0 Votes"
Crystal-MSFT answered Crystal-MSFT commented

@dilannanayakkara-8008, Research and find usersLoggedOn stores the last logged on user object id of a device. We can see more details in the following link:
https://docs.microsoft.com/en-us/graph/api/resources/intune-devices-windowsmanageddevice?view=graph-rest-beta
https://docs.microsoft.com/en-us/graph/api/intune-devices-windowsmanageddevice-get?view=graph-rest-beta

Here is the one device result when I check in Graph explorer:
82527-image.png

Research more and find a link describe bulk change all Intune device Primary Users to last logged on user. maybe it can be helpful to you.
https://svdbusse.github.io/SemiAnnualChat/2020/03/21/Changing-Intune-Primary-User-To-Last-Logged-On-User.html
Note: Non-Microsoft link, just for the reference.

Hope it can help.


If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



image.png (103.6 KiB)
· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@Crystal-MSFT Thank you very much for the response.

I have try out the above method to take a logon details and it is working fine. I was just wondering whether there is any possibility of getting the user login details from PowerShell. I have tried the below query on PowerShell but not able to get user logon details.

83603-2021-04-01-13-57-24.png


Thanks,
Dilan


0 Votes 0 ·
Crystal-MSFT avatar image Crystal-MSFT dilannanayakkara-8008 ·

@dilannanayakkara-8008, Based on my checking, there's no such function in PowerShell now. We can refer to the function "Get-Win10IntuneManagedDevice" in the following script to write a similar one to get the LastloggedOn information from graph.
https://github.com/microsoftgraph/powershell-intune-samples/blob/master/ManagedDevices/Win10_PrimaryUser_Set.ps1
Note Non-Microsoft link, just for the reference.

Hope it can help.

0 Votes 0 ·