Choose the permission or permissions marked as least privileged for this API. Use a higher privileged permission or permissions only if your app requires it. For details about delegated and application permissions, see Permission types. To learn more about these permissions, see the permissions reference.
Permission type
Least privileged permissions
Higher privileged permissions
Delegated (work or school account)
Directory.AccessAsUser.All
Not available.
Delegated (personal Microsoft account)
Not supported.
Not supported.
Application
Device.ReadWrite.All
Directory.ReadWrite.All
In application-only scenarios and for non-Windows devices, that is, where the operatingSystem property is not Windows, the app can update only the extensionAttributes property.
The calling user must also be in one of the following Microsoft Entra roles: Global Administrator, Intune Administrator. A calling user in the Cloud Device Administrator role can only enable or disable devices using this API and a user with the Windows 365 Administrator role can only update basic device properties.
HTTP request
You can address the device using either its id or deviceId.
In the request body, supply the values for the device properties that should be updated. Existing properties that are not included in the request body will maintain their previous values or be recalculated based on changes to other property values. For best performance you shouldn't include existing values that haven't changed.
Property
Type
Description
accountEnabled
Boolean
true if the account is enabled; otherwise, false. Only callers in Global Administrator and Cloud Device Administrator roles can update this property.
operatingSystem
String
The type of operating system on the device.
operatingSystemVersion
String
The version of the operating system on the device
displayName
String
The display name for the device.
isCompliant
Boolean
true if the device complies with Mobile Device Management (MDM) policies; otherwise, false. This can only be updated by Intune for any device OS type or by an approved MDM app for Windows OS devices.
isManaged
Boolean
true if the device is managed by a Mobile Device Management (MDM) app; otherwise, false. This can only be updated by Intune for any device OS type or by an approved MDM app for Windows OS devices.
Response
If successful, this method returns a 204 No Content response code.
Examples
Example 1: Update the accountEnabled property of a device
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new Device
{
AccountEnabled = false,
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Devices["{device-id}"].PatchAsync(requestBody);
<?php
// THIS SNIPPET IS A PREVIEW VERSION OF THE SDK. NON-PRODUCTION USE ONLY
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new Device();
$requestBody->setAccountEnabled(false);
$result = $graphServiceClient->devices()->byDeviceId('device-id')->patch($requestBody)->wait();
# THE PYTHON SDK IS IN PREVIEW. FOR NON-PRODUCTION USE ONLY
graph_client = GraphServiceClient(credentials, scopes)
request_body = Device(
account_enabled = False,
)
result = await graph_client.devices.by_device_id('device-id').patch(request_body)
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new Device
{
AdditionalData = new Dictionary<string, object>
{
{
"extensionAttributes" , new
{
ExtensionAttribute1 = "BYOD-Device",
}
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Devices["{device-id}"].PatchAsync(requestBody);
// THE CLI IS IN PREVIEW. NON-PRODUCTION USE ONLY
mgc devices patch --device-id {device-id} --body '{\
"extensionAttributes": {\
"extensionAttribute1": "BYOD-Device"\
}\
}\
'
<?php
// THIS SNIPPET IS A PREVIEW VERSION OF THE SDK. NON-PRODUCTION USE ONLY
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new Device();
$additionalData = [
'extensionAttributes' => [
'extensionAttribute1' => 'BYOD-Device',
],
];
$requestBody->setAdditionalData($additionalData);
$result = $graphServiceClient->devices()->byDeviceId('device-id')->patch($requestBody)->wait();
# THE PYTHON SDK IS IN PREVIEW. FOR NON-PRODUCTION USE ONLY
graph_client = GraphServiceClient(credentials, scopes)
request_body = Device(
additional_data = {
"extension_attributes" : {
"extension_attribute1" : "BYOD-Device",
},
}
)
result = await graph_client.devices.by_device_id('device-id').patch(request_body)