名前空間: microsoft.graph
重要
Microsoft Graph の /beta バージョンの API は変更される可能性があります。 実稼働アプリケーションでこれらの API を使用することは、サポートされていません。 v1.0 で API を使用できるかどうかを確認するには、Version セレクターを使用します。
デバイスのプロパティを更新します。 承認されたモバイル デバイス管理 (MDM) アプリを使用して、デバイスの特定のプロパティのみを更新できます。
この API は、次の国内クラウド展開で使用できます。
| グローバル サービス |
米国政府機関 L4 |
米国政府機関 L5 (DOD) |
21Vianet が運営する中国 |
| ✅ |
✅ |
✅ |
✅ |
アクセス許可
この API の最小特権としてマークされているアクセス許可またはアクセス許可を選択します。
アプリで必要な場合にのみ、より高い特権のアクセス許可またはアクセス許可を使用します。 委任されたアクセス許可とアプリケーションのアクセス許可の詳細については、「アクセス許可の種類」を参照してください。 これらのアクセス許可の詳細については、「アクセス許可のリファレンス」を参照してください。
| アクセス許可の種類 |
最小特権アクセス許可 |
より高い特権のアクセス許可 |
| 委任 (職場または学校のアカウント) |
Directory.AccessAsUser.All |
注意事項なし。 |
| 委任 (個人用 Microsoft アカウント) |
サポートされていません。 |
サポートされていません。 |
| アプリケーション |
Device.ReadWrite.All |
Directory.ReadWrite.All |
アプリケーションのみのシナリオや Windows 以外のデバイスの場合、つまり 、operatingSystem プロパティが Windowsされていない場合、アプリは extensionAttributes プロパティのみを更新できます。
重要
職場または学校アカウントを使用した委任されたシナリオでは、サインインしているユーザーに、サポートされているMicrosoft Entraロールまたはサポートされているロールのアクセス許可を持つカスタム ロールを割り当てる必要があります。
Intune管理者は、この操作でサポートされる最小限の特権ロールです。
Cloud Device Administrator ロールの呼び出し元ユーザーは、デバイスのみを有効または無効にでき、Windows 365管理者ロールを持つユーザーは基本的なデバイス プロパティのみを更新できます。
HTTP 要求
ID またはdeviceId を使用してデバイスをアドレス指定できます。
PATCH /devices/{id}
PATCH /devices(deviceId='{deviceId}')
| 名前 |
説明 |
| Authorization |
ベアラー {token}。 必須です。
認証と認可についての詳細をご覧ください。 |
要求本文
要求本文で、更新するデバイス プロパティの値を指定します。 要求本文に含まれない既存のプロパティは、以前の値のままになるか、他のプロパティ値の変化に基づいて再計算されます。 最適なパフォーマンスを得るためには、変更されていない既存の値を含めないでください。
| プロパティ |
型 |
説明 |
| accountEnabled |
Boolean |
アカウントが有効な場合は true であり、それ以外の場合は false です。 このプロパティを更新できるのは、少なくとも クラウド デバイス管理者 ロールを持つ呼び出し元のみです。 |
| alternativeNames |
String コレクション |
デバイスの代替名の一覧 (たとえば、 resourceIds)。 |
| displayName |
String |
デバイスの表示名。 |
| isCompliant |
ブール値 |
trueデバイスがモバイル デバイス管理 (MDM) ポリシーに準拠している場合は 。それ以外の場合は、false。 これは、任意のデバイス OS の種類のIntune、または Windows OS デバイス用の承認済みの MDM アプリによってのみ更新できます。 |
| isManaged |
ブール値 |
trueデバイスがモバイル デバイス管理 (MDM) アプリによって管理されている場合は 。それ以外の場合は、false。 これは、任意のデバイス OS の種類のIntune、または Windows OS デバイス用の承認済みの MDM アプリによってのみ更新できます。 |
| operatingSystem |
String |
デバイス上のオペレーティング システムの種類。 |
| operatingSystemVersion |
String |
デバイス上のオペレーティング システムのバージョン。 |
デバイス リソースは拡張機能をサポートしているため、PATCH操作を使用して、既存のデバイス インスタンスの拡張機能のカスタム プロパティで独自のアプリ固有データを追加、更新、または削除できます。
応答
成功した場合、このメソッドは 204 No Content 応答コードを返します。
例
例 1: デバイスの accountEnabled プロパティを更新する
要求
PATCH https://graph.microsoft.com/beta/devices/7c06cd31-7c30-4f3b-a5c3-444cd8dd63ac
Content-type: application/json
{
"accountEnabled": false
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.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);
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewDevice()
accountEnabled := false
requestBody.SetAccountEnabled(&accountEnabled)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
devices, err := graphClient.Devices().ByDeviceId("device-id").Patch(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
Device device = new Device();
device.setAccountEnabled(false);
Device result = graphClient.devices().byDeviceId("{device-id}").patch(device);
const options = {
authProvider,
};
const client = Client.init(options);
const device = {
accountEnabled: false
};
await client.api('/devices/7c06cd31-7c30-4f3b-a5c3-444cd8dd63ac')
.version('beta')
.update(device);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\Device;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new Device();
$requestBody->setAccountEnabled(false);
$result = $graphServiceClient->devices()->byDeviceId('device-id')->patch($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Identity.DirectoryManagement
$params = @{
accountEnabled = $false
}
Update-MgBetaDevice -DeviceId $deviceId -BodyParameter $params
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.models.device import Device
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = Device(
account_enabled = False,
)
result = await graph_client.devices.by_device_id('device-id').patch(request_body)
応答
HTTP/1.1 204 No Content
例 2: デバイスに extensionAttributes を書き込む
要求
PATCH https://graph.microsoft.com/beta/devices/7c06cd31-7c30-4f3b-a5c3-444cd8dd63ac
Content-type: application/json
{
"extensionAttributes": {
"extensionAttribute1": "BYOD-Device"
}
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new Device
{
ExtensionAttributes = new OnPremisesExtensionAttributes
{
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);
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewDevice()
extensionAttributes := graphmodels.NewOnPremisesExtensionAttributes()
extensionAttribute1 := "BYOD-Device"
extensionAttributes.SetExtensionAttribute1(&extensionAttribute1)
requestBody.SetExtensionAttributes(extensionAttributes)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
devices, err := graphClient.Devices().ByDeviceId("device-id").Patch(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
Device device = new Device();
OnPremisesExtensionAttributes extensionAttributes = new OnPremisesExtensionAttributes();
extensionAttributes.setExtensionAttribute1("BYOD-Device");
device.setExtensionAttributes(extensionAttributes);
Device result = graphClient.devices().byDeviceId("{device-id}").patch(device);
const options = {
authProvider,
};
const client = Client.init(options);
const device = {
extensionAttributes: {
extensionAttribute1: 'BYOD-Device'
}
};
await client.api('/devices/7c06cd31-7c30-4f3b-a5c3-444cd8dd63ac')
.version('beta')
.update(device);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\Device;
use Microsoft\Graph\Beta\Generated\Models\OnPremisesExtensionAttributes;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new Device();
$extensionAttributes = new OnPremisesExtensionAttributes();
$extensionAttributes->setExtensionAttribute1('BYOD-Device');
$requestBody->setExtensionAttributes($extensionAttributes);
$result = $graphServiceClient->devices()->byDeviceId('device-id')->patch($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Identity.DirectoryManagement
$params = @{
extensionAttributes = @{
extensionAttribute1 = "BYOD-Device"
}
}
Update-MgBetaDevice -DeviceId $deviceId -BodyParameter $params
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.models.device import Device
from msgraph_beta.generated.models.on_premises_extension_attributes import OnPremisesExtensionAttributes
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = Device(
extension_attributes = OnPremisesExtensionAttributes(
extension_attribute1 = "BYOD-Device",
),
)
result = await graph_client.devices.by_device_id('device-id').patch(request_body)
応答
HTTP/1.1 204 No Content
関連コンテンツ