how to disassociate a device from specific user in Microsoft Entra without deleting the device itself ( there is an image of the problem attached )

62498367 5 Reputation points
2024-01-29T11:23:41.38+00:00

the problem is highlighted

Microsoft Security | Microsoft Entra | Microsoft Entra ID
{count} vote

1 answer

Sort by: Most helpful
  1. Alfredo Revilla - Upwork Top Talent | IAM SWE SWA 27,526 Reputation points Moderator
    2024-01-29T22:28:12.65+00:00

    Hello @62498367 , to remove a registered user from Entra ID device you can leverage the Microsoft Graph PowerShell SDK and the MSAL.PS module. Eg.

    # Replace the following variables
    $TenantId = "string"
    $DeviceObjectId = "guid"
    $UserId = "guid"
    
    $ClientId = "17a6e0ad-a3ea-4364-9b1a-f0bdc4af8dde"
    
    $token = Get-MsalToken -ClientId $ClientId -TenantId $TenantId -Interactive  -Scopes ".default"
    
    Connect-MgGraph -AccessToken ($token.AccessToken | ConvertTo-SecureString -AsPlainText -Force) -NoWelcome
    
    Remove-MgDeviceRegisteredUserByRef -DeviceId $DeviceObjectId -DirectoryObjectId $UserId
    

    Full PowerShell function available here.

    Let us know if you need additional assistance. If the answer was helpful, please accept it and rate it so that others facing a similar issue can easily find a solution.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.