Create deviceManagementScriptDeviceState
Namespace: microsoft.graph
Important: Microsoft Graph APIs under the /beta version are subject to change; production use is not supported.
Note: The Microsoft Graph API for Intune requires an active Intune license for the tenant.
Create a new deviceManagementScriptDeviceState object.
This API is available in the following national cloud deployments.
Global service | US Government L4 | US Government L5 (DOD) | China operated by 21Vianet |
---|---|---|---|
✅ | ✅ | ✅ | ✅ |
Permissions
One of the following permissions is required to call this API. To learn more, including how to choose permissions, see Permissions.
Permission type | Permissions (from least to most privileged) |
---|---|
Delegated (work or school account) | DeviceManagementConfiguration.ReadWrite.All, DeviceManagementManagedDevices.ReadWrite.All |
Delegated (personal Microsoft account) | Not supported. |
Application | DeviceManagementConfiguration.ReadWrite.All, DeviceManagementManagedDevices.ReadWrite.All |
HTTP Request
POST /deviceManagement/deviceShellScripts/{deviceShellScriptId}/deviceRunStates
POST /deviceManagement/deviceManagementScripts/{deviceManagementScriptId}/deviceRunStates
POST /deviceManagement/deviceCustomAttributeShellScripts/{deviceCustomAttributeShellScriptId}/deviceRunStates
POST /deviceManagement/deviceManagementScripts/{deviceManagementScriptId}/userRunStates/{deviceManagementScriptUserStateId}/deviceRunStates
Request headers
Header | Value |
---|---|
Authorization | Bearer {token}. Required. Learn more about authentication and authorization. |
Accept | application/json |
Request body
In the request body, supply a JSON representation for the deviceManagementScriptDeviceState object.
The following table shows the properties that are required when you create the deviceManagementScriptDeviceState.
Property | Type | Description |
---|---|---|
id | String | Key of the device management script device state entity. This property is read-only. |
runState | runState | State of latest run of the device management script. Possible values are: unknown , success , fail , scriptError , pending , notApplicable . |
resultMessage | String | Details of execution output. |
lastStateUpdateDateTime | DateTimeOffset | Latest time the device management script executes. |
errorCode | Int32 | Error code corresponding to erroneous execution of the device management script. |
errorDescription | String | Error description corresponding to erroneous execution of the device management script. |
Response
If successful, this method returns a 201 Created
response code and a deviceManagementScriptDeviceState object in the response body.
Example
Request
Here is an example of the request.
POST https://graph.microsoft.com/beta/deviceManagement/deviceShellScripts/{deviceShellScriptId}/deviceRunStates
Content-type: application/json
Content-length: 281
{
"@odata.type": "#microsoft.graph.deviceManagementScriptDeviceState",
"runState": "success",
"resultMessage": "Result Message value",
"lastStateUpdateDateTime": "2017-01-01T00:02:58.4418045-08:00",
"errorCode": 9,
"errorDescription": "Error Description value"
}
Response
Here is an example of the response. Note: The response object shown here may be truncated for brevity. All of the properties will be returned from an actual call.
HTTP/1.1 201 Created
Content-Type: application/json
Content-Length: 330
{
"@odata.type": "#microsoft.graph.deviceManagementScriptDeviceState",
"id": "39440cba-0cba-3944-ba0c-4439ba0c4439",
"runState": "success",
"resultMessage": "Result Message value",
"lastStateUpdateDateTime": "2017-01-01T00:02:58.4418045-08:00",
"errorCode": 9,
"errorDescription": "Error Description value"
}