获取 cloudPC
本文内容
命名空间:microsoft.graph
重要
Microsoft Graph /beta
版本下的 API 可能会发生更改。 不支持在生产应用程序中使用这些 API。 若要确定 API 是否在 v1.0 中可用,请使用 版本 选择器。
读取特定 cloudPC 对象的属性和关系。
此 API 可用于以下国家级云部署 。
全局服务
美国政府 L4
美国政府 L5 (DOD)
由世纪互联运营的中国
✅
✅
✅
❌
权限
为此 API 选择标记为最低特权的权限。 只有在应用需要它时 ,才使用更高的特权权限。 有关委派权限和应用程序权限的详细信息,请参阅权限类型 。 要了解有关这些权限的详细信息,请参阅 权限参考 。
权限类型
最低特权权限
更高特权权限
委派(工作或学校帐户)
CloudPC.Read.All
CloudPC.ReadWrite.All
委派(个人 Microsoft 帐户)
不支持。
不支持。
应用程序
CloudPC.Read.All
CloudPC.ReadWrite.All
HTTP 请求
若要获取指定用户的 cloudPC , (谁是组织中的已登录用户) 使用委派的权限:
GET /me/cloudPCs/{id}
GET /users/{userId}/cloudPCs/{id}
若要获取组织中的指定 cloudPC ,请使用委派权限 (登录用户应是管理员) 或应用程序权限:
GET /deviceManagement/virtualEndpoint/cloudPCs/{id}
可选的查询参数
此方法支持 $select
OData 查询参数来帮助自定义响应。 若要了解一般信息,请参阅 OData 查询参数 。
名称
说明
Authorization
持有者 {token}。 必填。 详细了解 身份验证和授权 。
请求正文
请勿提供此方法的请求正文。
响应
如果成功,此方法在 200 OK
响应正文中返回响应代码和 cloudPC 对象。
示例
示例 1:获取云电脑的默认属性
请求
以下示例显示了一个请求。
GET https://graph.microsoft.com/beta/deviceManagement/virtualEndpoint/cloudPCs/9ec90ff8-fd63-4fb9-ab5a-aa4fdcc43ec9
// 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.DeviceManagement.VirtualEndpoint.CloudPCs["{cloudPC-id}"].GetAsync();
// THE CLI IS IN PREVIEW. NON-PRODUCTION USE ONLY
mgc-beta device-management virtual-endpoint cloud-pcs get --cloud-pcid {cloudPC-id}
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
//other-imports
)
graphClient := msgraphsdk.NewGraphServiceClientWithCredentials(cred, scopes)
cloudPCs, err := graphClient.DeviceManagement().VirtualEndpoint().CloudPCs().ByCloudPCId("cloudPC-id").Get(context.Background(), nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
CloudPC result = graphClient.deviceManagement().virtualEndpoint().cloudPCs().byCloudPCId("{cloudPC-id}").get();
const options = {
authProvider,
};
const client = Client.init(options);
let cloudPC = await client.api('/deviceManagement/virtualEndpoint/cloudPCs/9ec90ff8-fd63-4fb9-ab5a-aa4fdcc43ec9')
.version('beta')
.get();
<?php
use Microsoft\Graph\GraphServiceClient;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$result = $graphServiceClient->deviceManagement()->virtualEndpoint()->cloudPCs()->byCloudPCId('cloudPC-id')->get()->wait();
Import-Module Microsoft.Graph.Beta.DeviceManagement.Administration
Get-MgBetaDeviceManagementVirtualEndpointCloudPc -CloudPCId $cloudPCId
from msgraph import GraphServiceClient
graph_client = GraphServiceClient(credentials, scopes)
result = await graph_client.device_management.virtual_endpoint.cloud_p_cs.by_cloud_p_c_id('cloudPC-id').get()
响应
以下示例显示了相应的响应。
HTTP/1.1 200 OK
Content-Type: application/json
{
"@odata.type": "#microsoft.graph.cloudPC",
"aadDeviceId": "f5ff445f-7488-40f8-8ab9-ee784a9c1f33",
"id": "ac74ae8b-85f7-4272-88cc-54192674ffff",
"displayName": "Demo-0",
"imageDisplayName": "Windows-10 19h1-evd",
"managedDeviceId": "e87f50c7-fa7f-4687-aade-dd45f3d6ffff",
"managedDeviceName": "A00002GI001",
"provisioningPolicyId": "13fa0778-ba00-438a-96d3-488c8602ffff",
"provisioningPolicyName": "Marketing provisioning policy",
"onPremisesConnectionName": "Azure network connection for Marketing",
"servicePlanId": "da5615b4-a484-4742-a019-2d52c91cffff",
"servicePlanName": "standard",
"servicePlanType": "enterprise",
"status": "failed",
"statusDetails": {
"@odata.type": "microsoft.graph.cloudPcStatusDetails",
"code": "internalServerError",
"message": "There was an internal server error. Please contact support xxx.",
"additionalInformation": [
{
"@odata.type": "microsoft.graph.keyValuePair",
"name": "correlationId",
"value": "52367774-cfb7-4e9c-ab51-1b864c31f2d1"
}
]
},
"userPrincipalName": "pmitchell@contoso.com",
"lastModifiedDateTime": "2020-11-03T18:14:34Z",
"gracePeriodEndDateTime": "2020-11-010T20:00:34Z",
"provisioningType": "shared",
"diskEncryptionState": "notAvailable"
}
示例 2:获取云电脑的选定属性
请求
以下示例显示了一个请求。
GET https://graph.microsoft.com/beta/deviceManagement/virtualEndpoint/cloudPCs/40cee9d2-03fb-4066-8d35-dbdf2875c33f?$select=id,displayName,imageDisplayName,lastModifiedDateTime,lastRemoteActionResult,lastLoginResult,connectivityResult
// 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.DeviceManagement.VirtualEndpoint.CloudPCs["{cloudPC-id}"].GetAsync((requestConfiguration) =>
{
requestConfiguration.QueryParameters.Select = new string []{ "id","displayName","imageDisplayName","lastModifiedDateTime","lastRemoteActionResult","lastLoginResult","connectivityResult" };
});
// THE CLI IS IN PREVIEW. NON-PRODUCTION USE ONLY
mgc-beta device-management virtual-endpoint cloud-pcs get --cloud-pcid {cloudPC-id} --select "id,displayName,imageDisplayName,lastModifiedDateTime,lastRemoteActionResult,lastLoginResult,connectivityResult"
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphdevicemanagement "github.com/microsoftgraph/msgraph-beta-sdk-go/devicemanagement"
//other-imports
)
graphClient := msgraphsdk.NewGraphServiceClientWithCredentials(cred, scopes)
requestParameters := &graphdevicemanagement.DeviceManagementVirtualEndpointCloudPCItemRequestBuilderGetQueryParameters{
Select: [] string {"id","displayName","imageDisplayName","lastModifiedDateTime","lastRemoteActionResult","lastLoginResult","connectivityResult"},
}
configuration := &graphdevicemanagement.DeviceManagementVirtualEndpointCloudPCItemRequestBuilderGetRequestConfiguration{
QueryParameters: requestParameters,
}
cloudPCs, err := graphClient.DeviceManagement().VirtualEndpoint().CloudPCs().ByCloudPCId("cloudPC-id").Get(context.Background(), configuration)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
CloudPC result = graphClient.deviceManagement().virtualEndpoint().cloudPCs().byCloudPCId("{cloudPC-id}").get(requestConfiguration -> {
requestConfiguration.queryParameters.select = new String []{"id", "displayName", "imageDisplayName", "lastModifiedDateTime", "lastRemoteActionResult", "lastLoginResult", "connectivityResult"};
});
const options = {
authProvider,
};
const client = Client.init(options);
let cloudPC = await client.api('/deviceManagement/virtualEndpoint/cloudPCs/40cee9d2-03fb-4066-8d35-dbdf2875c33f')
.version('beta')
.select('id,displayName,imageDisplayName,lastModifiedDateTime,lastRemoteActionResult,lastLoginResult,connectivityResult')
.get();
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\DeviceManagement\VirtualEndpoint\CloudPCs\Item\CloudPCItemRequestBuilderGetRequestConfiguration;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestConfiguration = new CloudPCItemRequestBuilderGetRequestConfiguration();
$queryParameters = CloudPCItemRequestBuilderGetRequestConfiguration::createQueryParameters();
$queryParameters->select = ["id","displayName","imageDisplayName","lastModifiedDateTime","lastRemoteActionResult","lastLoginResult","connectivityResult"];
$requestConfiguration->queryParameters = $queryParameters;
$result = $graphServiceClient->deviceManagement()->virtualEndpoint()->cloudPCs()->byCloudPCId('cloudPC-id')->get($requestConfiguration)->wait();
Import-Module Microsoft.Graph.Beta.DeviceManagement.Administration
Get-MgBetaDeviceManagementVirtualEndpointCloudPc -CloudPCId $cloudPCId -Property "id,displayName,imageDisplayName,lastModifiedDateTime,lastRemoteActionResult,lastLoginResult,connectivityResult"
from msgraph import GraphServiceClient
from msgraph.generated.deviceManagement.virtualEndpoint.cloudPCs.item.cloud_p_c_item_request_builder import CloudPCItemRequestBuilder
graph_client = GraphServiceClient(credentials, scopes)
query_params = CloudPCItemRequestBuilder.CloudPCItemRequestBuilderGetQueryParameters(
select = ["id","displayName","imageDisplayName","lastModifiedDateTime","lastRemoteActionResult","lastLoginResult","connectivityResult"],
)
request_configuration = CloudPCItemRequestBuilder.CloudPCItemRequestBuilderGetRequestConfiguration(
query_parameters = query_params,
)
result = await graph_client.device_management.virtual_endpoint.cloud_p_cs.by_cloud_p_c_id('cloudPC-id').get(request_configuration = request_configuration)
响应
以下示例显示了相应的响应。
HTTP/1.1 200 OK
Content-Type: application/json
{
"@odata.type": "#microsoft.graph.cloudPC",
"id": "ac74ae8b-85f7-4272-88cc-54192674ffff",
"displayName": "Demo-0",
"imageDisplayName": "Windows-10 19h1-evd",
"lastModifiedDateTime": "2020-11-03T18:14:34Z",
"lastLoginResult": {
"time": "2021-06-23T09:28:32.8260335Z"
},
"lastRemoteActionResult": {
"actionName": "Reboot",
"actionState": "done",
"startDateTime": "2021-06-23T09:28:32.8260335Z",
"lastUpdatedDateTime": "2021-06-23T09:28:32.8260338Z",
"cloudPcId": "662009bc-7732-4f6f-8726-25883518b33e",
"managedDeviceId": "bdc8e6dd-0455-4412-83d9-c818664fe1f1",
"statusDetails": null
},
"connectivityResult": {
"status": "unavailable",
"updatedDatetime": "2022-03-22T10:28:32.8260335Z",
"failedHealthCheckItems": [
{
"displayName": "DomainJoinCheck",
"result": "failure",
"lastHealthCheckDateTime": "2022-03-22T10:28:32.8260335Z",
"additionalDetails": "SessionHost unhealthy: SessionHost is not joined to a domain"
}
]
}
}
Exmaple 3:获取已登录用户的云电脑的默认属性
请求
以下示例显示了一个请求。
GET https://graph.microsoft.com/beta/me/cloudPCs/36bd4942-0ca8-11ed-861d-0242ac120002
// 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.Me.CloudPCs["{cloudPC-id}"].GetAsync();
// THE CLI IS IN PREVIEW. NON-PRODUCTION USE ONLY
mgc-beta users cloud-pcs get --user-id {user-id} --cloud-pcid {cloudPC-id}
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
//other-imports
)
graphClient := msgraphsdk.NewGraphServiceClientWithCredentials(cred, scopes)
cloudPCs, err := graphClient.Me().CloudPCs().ByCloudPCId("cloudPC-id").Get(context.Background(), nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
CloudPC result = graphClient.me().cloudPCs().byCloudPCId("{cloudPC-id}").get();
const options = {
authProvider,
};
const client = Client.init(options);
let cloudPC = await client.api('/me/cloudPCs/36bd4942-0ca8-11ed-861d-0242ac120002')
.version('beta')
.get();
<?php
use Microsoft\Graph\GraphServiceClient;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$result = $graphServiceClient->me()->cloudPCs()->byCloudPCId('cloudPC-id')->get()->wait();
from msgraph import GraphServiceClient
graph_client = GraphServiceClient(credentials, scopes)
result = await graph_client.me.cloud_p_cs.by_cloud_p_c_id('cloudPC-id').get()
响应
以下示例显示了相应的响应。
HTTP/1.1 200 OK
Content-Type: application/json
{
"@odata.type": "#microsoft.graph.cloudPC",
"aadDeviceId": "61204a22-0ca8-11ed-861d-0242ac120002",
"id": "36bd4942-0ca8-11ed-861d-0242ac120002",
"displayName": "Demo-1",
"imageDisplayName": "Windows-10 19h1-evd",
"managedDeviceId": "70341bb0-0ca8-11ed-861d-0242ac120002",
"managedDeviceName": "A00002GI001",
"provisioningPolicyId": "7a3bdee0-0ca8-11ed-861d-0242ac120002",
"provisioningPolicyName": "Marketing provisioning policy",
"onPremisesConnectionName": "Azure network connection for Marketing",
"servicePlanId": "83fca22a-0ca8-11ed-861d-0242ac120002",
"servicePlanName": "standard",
"servicePlanType": "enterprise",
"status": "failed",
"statusDetails": {
"@odata.type": "microsoft.graph.cloudPcStatusDetails",
"code": "internalServerError",
"message": "There was an internal server error. Please contact support xxx.",
"additionalInformation": [
{
"@odata.type": "microsoft.graph.keyValuePair",
"name": "correlationId",
"value": "8fea34e4-0ca8-11ed-861d-0242ac120002"
}
]
},
"userPrincipalName": "pmitchell@contoso.com",
"lastModifiedDateTime": "2020-11-03T18:14:34Z",
"gracePeriodEndDateTime": "2020-11-010T20:00:34Z",
"provisioningType": "shared",
"diskEncryptionState": "notAvailable"
}