Clear Device Category in Intune and set it to Unassigned (null)

Karim Ibrahim 25 Reputation points
2025-07-25T07:46:20.3833333+00:00

Hi,

I've been exploring a way to clear the Device Category for an Intune-managed device using a PowerShell script. I've registered an app with the necessary permissions, following the guidance from this Microsoft Q&A post, We've detected a Microsoft Intune PowerShell script issue in your environment and the script seems to executes without any errors. However, the device category in Intune remains unchanged.

Is it possible that setting the device category to null is not supported? Any insights or guidance on this would be greatly appreciated.

# Connect to MSGraph
Write-Host "Connecting to MSGraph..." -ForegroundColor Cyan
Update-MSGraphEnvironment -AppId xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Connect-MSGraph

$deviceId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
$baseUrl = "https://graph.microsoft.com"
$graphApiVersion = "beta"
$deviceUri = "$baseUrl/$graphApiVersion/deviceManagement/managedDevices/$deviceId"
$Body = @{ deviceCategoryId = $null } | ConvertTo-Json -Compress

Invoke-MgGraphRequest -Uri $deviceUri `
-Method PATCH `
-Body $Body `
-ContentType "application/json"

$updatedDevice = Get-MgDeviceManagementManagedDevice -ManagedDeviceId $deviceId
Write-Host "deviceCategoryDisplayName: $($updatedDevice.deviceCategoryDisplayName)"

Microsoft Security | Intune | Configuration
{count} vote

Accepted answer
  1. Prathista Ilango 345 Reputation points Microsoft Employee
    2025-07-31T12:02:39.3666667+00:00

    Hello Karim Ibrahim,

    The following script changes the device category to unassigned. Hope this helps.

    # Connect to MSGraph
    Write-Host "Connecting to MSGraph..." -ForegroundColor Cyan
    Update-MSGraphEnvironment -AppId 'xxxxxxxx-xxxx-xxxx-xxxxxxxxxxx'
    Connect-MSGraph
    
    function Unassign-DeviceCategory {
    	param(
    		[Parameter(Mandatory)]
    		[string]$DeviceID,
    		
    		[Parameter(Mandatory)]
    		[string]$DeviceCategory
    	)
        
        $body = @{ "@odata.id" = "https://graph.microsoft.com/beta/deviceManagement/deviceCategories/$DeviceCategory" }
        Invoke-MSGraphRequest -HttpMethod PUT -Url "deviceManagement/managedDevices/$DeviceID/deviceCategory/`$ref" -Content $body
    }
    $DeviceID = 'xxxxxxxx-xxxx-xxxx-xxxxxxxxxxx'
    $DeviceCategory = '00000000-0000-0000-0000-000000000000'
    Unassign-DeviceCategory -DeviceID $DeviceID -DeviceCategory $DeviceCategory
    
    
    

    If you found the information above helpful, please Accept the answer. This will assist others in the community who encounter a similar issue, enabling them to quickly find the solution and benefit from the guidance provided.

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Joe 0 Reputation points
    2025-07-30T17:08:21.6533333+00:00

    Just found that the Unassigned CategoryID is 00000000-0000-0000-0000-000000000000 . It worked setting a device to that ID.


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.