名前空間: microsoft.graph
重要
Microsoft Graph の /beta
バージョンの API は変更される可能性があります。 実稼働アプリケーションでこれらの API を使用することは、サポートされていません。 v1.0 で API を使用できるかどうかを確認するには、Version セレクターを使用します。
デバイス オブジェクトのプロパティとリレーションシップを取得します。
デバイス リソースでは拡張機能がサポートされているため、GET
操作を使用して、デバイス インスタンス内のカスタム プロパティと拡張機能データを取得することもできます。
この API は、次の国内クラウド展開で使用できます。
グローバル サービス |
米国政府機関 L4 |
米国政府機関 L5 (DOD) |
21Vianet が運営する中国 |
✅ |
✅ |
✅ |
✅ |
アクセス許可
この API の最小特権としてマークされているアクセス許可またはアクセス許可を選択します。
アプリで必要な場合にのみ、より高い特権のアクセス許可またはアクセス許可を使用します。 委任されたアクセス許可とアプリケーションのアクセス許可の詳細については、「アクセス許可の種類」を参照してください。 これらのアクセス許可の詳細については、「アクセス許可のリファレンス」を参照してください。
アクセス許可の種類 |
最小特権アクセス許可 |
より高い特権のアクセス許可 |
委任 (職場または学校のアカウント) |
Device.Read.All |
Directory.Read.All、Directory.ReadWrite.All |
委任 (個人用 Microsoft アカウント) |
サポートされていません。 |
サポートされていません。 |
アプリケーション |
Device.Read.All |
Device.ReadWrite.All、Directory.Read.All、Directory.ReadWrite.All |
重要
職場または学校アカウントを使用した委任されたシナリオでは、サインインしているユーザーに、サポートされているMicrosoft Entraロールまたはサポートされているロールのアクセス許可を持つカスタム ロールを割り当てる必要があります。 この操作では、次の最小特権ロールがサポートされています。
- ユーザー
- ディレクトリ リーダー
- ディレクトリ製作者
- コンプライアンス管理者
- デバイス マネージャー
- アプリケーション管理者
- セキュリティ閲覧者
- セキュリティ管理者
- 特権ロール管理者
- クラウド アプリケーション管理者
- カスタマー ロックボックス アクセス承認者
- Dynamics 365管理者
- Power BI 管理者
- Desktop Analytics管理者
- Microsoft マネージド デスクトップ管理者
- Teams 通信管理者
- Teams 通信サポート エンジニア
- Teams 通信サポート スペシャリスト
- Teams 管理者
- コンプライアンス データ管理者
- セキュリティ オペレーター
- Kaizala 管理者
- グローバル閲覧者
- ディレクトリレビュー担当者
- Windows 365 管理者
HTTP 要求
ID またはdeviceId を使用してデバイスをアドレス指定できます。
GET /devices/{id}
GET /devices(deviceId='{deviceId}')
オプションのクエリ パラメーター
このメソッドは、応答のカスタマイズに役立つ $select
OData クエリ パラメーター をサポートします。
名前 |
説明 |
Authorization |
ベアラー {token}。 必須です。
認証と認可についての詳細をご覧ください。 |
要求本文
このメソッドには、要求本文を指定しません。
応答
成功した場合、このメソッドは200 OK
応答コードと、応答本文でデバイス オブジェクトを返します。
例
例 1: デバイスを取得する
要求
次の例は要求を示しています。
GET https://graph.microsoft.com/beta/devices/000005c3-b7a6-4c61-89fc-80bf5ccfc366
// Code snippets are only available for the latest version. Current version is 5.x
// 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}"].GetAsync();
mgc-beta devices get --device-id {device-id}
// 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"
//other-imports
)
// 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").Get(context.Background(), nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
Device result = graphClient.devices().byDeviceId("{device-id}").get();
const options = {
authProvider,
};
const client = Client.init(options);
let device = await client.api('/devices/000005c3-b7a6-4c61-89fc-80bf5ccfc366')
.version('beta')
.get();
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$result = $graphServiceClient->devices()->byDeviceId('device-id')->get()->wait();
Import-Module Microsoft.Graph.Beta.Identity.DirectoryManagement
Get-MgBetaDevice -DeviceId $deviceId
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
result = await graph_client.devices.by_device_id('device-id').get()
応答
次の例は、 hostNames のないデバイスの応答を示しています。
注: ここに示す応答オブジェクトは、読みやすさのために短縮されている場合があります。
HTTP/1.1 200 OK
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#devices/$entity",
"@odata.id": "https://graph.microsoft.com/v2/72f988bf-86f1-41af-91ab-2d7cd011db47/directoryObjects/000005c3-b7a6-4c61-89fc-80bf5ccfc366/Microsoft.DirectoryServices.Device",
"accountEnabled": true,
"approximateLastSignInDateTime": "2021-08-26T21:15:01Z",
"deviceId": "000005c3-b7a6-4c61-89fc-80bf5ccfc366",
"deviceMetadata": null,
"deviceVersion": 2,
"hostNames": []
}
次の例は、 hostNames を持つデバイスの応答を示しています。
注: ここに示す応答オブジェクトは、読みやすさのために短縮されている場合があります。
HTTP/1.1 200 OK
Content-type: application/json
{
"accountEnabled": true,
"approximateLastSignInDateTime": "2016-10-19T10:37:00Z",
"deviceId": "deviceId-value",
"deviceMetadata": "deviceMetadata-value",
"deviceVersion": 99,
"hostnames":["contoso.com", "hostname1"]
}
例 2: デバイスを取得し、その ID と extensionAttributes プロパティのみを返す
要求
次の要求は、デバイスの ID と extensionAttributes プロパティを取得します。
GET https://graph.microsoft.com/beta/devices/6a59ea83-02bd-468f-a40b-f2c3d1821983?$select=id,extensionAttributes
// Code snippets are only available for the latest version. Current version is 5.x
// 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}"].GetAsync((requestConfiguration) =>
{
requestConfiguration.QueryParameters.Select = new string []{ "id","extensionAttributes" };
});
mgc-beta devices get --device-id {device-id} --select "id,extensionAttributes"
// 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"
graphdevices "github.com/microsoftgraph/msgraph-beta-sdk-go/devices"
//other-imports
)
requestParameters := &graphdevices.DeviceItemRequestBuilderGetQueryParameters{
Select: [] string {"id","extensionAttributes"},
}
configuration := &graphdevices.DeviceItemRequestBuilderGetRequestConfiguration{
QueryParameters: requestParameters,
}
// 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").Get(context.Background(), configuration)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
Device result = graphClient.devices().byDeviceId("{device-id}").get(requestConfiguration -> {
requestConfiguration.queryParameters.select = new String []{"id", "extensionAttributes"};
});
const options = {
authProvider,
};
const client = Client.init(options);
let device = await client.api('/devices/6a59ea83-02bd-468f-a40b-f2c3d1821983')
.version('beta')
.select('id,extensionAttributes')
.get();
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Devices\Item\DeviceItemRequestBuilderGetRequestConfiguration;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestConfiguration = new DeviceItemRequestBuilderGetRequestConfiguration();
$queryParameters = DeviceItemRequestBuilderGetRequestConfiguration::createQueryParameters();
$queryParameters->select = ["id","extensionAttributes"];
$requestConfiguration->queryParameters = $queryParameters;
$result = $graphServiceClient->devices()->byDeviceId('device-id')->get($requestConfiguration)->wait();
Import-Module Microsoft.Graph.Beta.Identity.DirectoryManagement
Get-MgBetaDevice -DeviceId $deviceId -Property "id,extensionAttributes"
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.devices.item.device_item_request_builder import DeviceItemRequestBuilder
from kiota_abstractions.base_request_configuration import RequestConfiguration
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
query_params = DeviceItemRequestBuilder.DeviceItemRequestBuilderGetQueryParameters(
select = ["id","extensionAttributes"],
)
request_configuration = RequestConfiguration(
query_parameters = query_params,
)
result = await graph_client.devices.by_device_id('device-id').get(request_configuration = request_configuration)
応答
次の例は応答を示しています。
HTTP/1.1 200 OK
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#devices(id,extensionAttributes)/$entity",
"id": "6a59ea83-02bd-468f-a40b-f2c3d1821983",
"extensionAttributes": {
"extensionAttribute1": null,
"extensionAttribute2": null,
"extensionAttribute3": null,
"extensionAttribute4": null,
"extensionAttribute5": null,
"extensionAttribute6": null,
"extensionAttribute7": null,
"extensionAttribute8": null,
"extensionAttribute9": null,
"extensionAttribute10": null,
"extensionAttribute11": null,
"extensionAttribute12": null,
"extensionAttribute13": null,
"extensionAttribute14": null,
"extensionAttribute15": null
}
}
関連コンテンツ