Via the MEM UI in the device overview you can see all assignments of a certain device. In the service release Service release 2206 even the function to see the group members of a device was included. But if you want to create automations it is helpful to be able to query this information with PowerShell. I have created a script at the request of a user in the community which returns this information to you.

How do I get the script
You can find the script in my Github repository. In addition to that I have also published the script in the PowerShell Gallery. Here you can download the script with the following command.
Install-Script -Name Get-AllDeviceAssignments
What does the script deliver
General device informations

Group memberships

Configuration profiles

Applications

[…] https://jannikreinhard.com/2023/01/29/get-assignments-of-an-device-via-powershell/ […]
LikeLike
Thanks for that – can it work with “nested groups” as it isn’t picking up all the assignments for my tenant. For example, device is a member of “Staff 121 Devices” and then this is a member of “All Intune Devices”. There are some apps and profiles delivered to the “top level” group.
LikeLike
Hey Darren, this should work because i filter for devices not for groups. Can you try it out and give me feedback if it not work.
LikeLike