Skip to content

Set-MgmtGraphDeviceCategory

MgmtGraph: Updates Intune device category properties

#Requires -Version 5.1
#Requires -Modules Microsoft.Graph.DeviceManagement

[CmdletBinding()]
Param (
    [Parameter(Mandatory = $true, Position = 0)]
    [string]$Identity,

    [string]$DisplayName,

    [string]$Description
)

Process {
    try {
        $params = @{
            'DeviceCategoryId' = $Identity
            'Confirm'          = $false
            'ErrorAction'      = 'Stop'
        }

        if ($DisplayName) { $params.Add('DisplayName', $DisplayName) }
        if ($Description) { $params.Add('Description', $Description) }

        if ($params.Count -gt 3) {
            Update-MgDeviceManagementDeviceCategory @params
            
            $result = [PSCustomObject]@{
                Id          = $Identity
                DisplayName = $DisplayName
                Action      = "DeviceCategoryUpdated"
                Status      = "Success"
                Timestamp   = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
            }
            Write-Output $result
        }
        else {
            Write-Warning "No properties specified to update for device category."
        }
    }
    catch {
        throw
    }
}

Specifies the ID of the device category to update.

Optional. Specifies the new display name for the device category.

Optional. Specifies the new description for the device category.

An interactive directory of PowerShell scripts.