POST https://graph.microsoft.com/v1.0/deviceManagement/deviceCompliancePolicies
Content-type: application/json
Content-length: 954
{
"@odata.type": "#microsoft.graph.windows10CompliancePolicy",
"description": "Description value",
"displayName": "Display Name value",
"version": 7,
"passwordRequired": true,
"passwordBlockSimple": true,
"passwordRequiredToUnlockFromIdle": true,
"passwordMinutesOfInactivityBeforeLock": 5,
"passwordExpirationDays": 6,
"passwordMinimumLength": 5,
"passwordMinimumCharacterSetCount": 0,
"passwordRequiredType": "alphanumeric",
"passwordPreviousPasswordBlockCount": 2,
"requireHealthyDeviceReport": true,
"osMinimumVersion": "Os Minimum Version value",
"osMaximumVersion": "Os Maximum Version value",
"mobileOsMinimumVersion": "Mobile Os Minimum Version value",
"mobileOsMaximumVersion": "Mobile Os Maximum Version value",
"earlyLaunchAntiMalwareDriverEnabled": true,
"bitLockerEnabled": true,
"secureBootEnabled": true,
"codeIntegrityEnabled": true,
"storageRequireEncryption": true
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new Windows10CompliancePolicy
{
OdataType = "#microsoft.graph.windows10CompliancePolicy",
Description = "Description value",
DisplayName = "Display Name value",
Version = 7,
PasswordRequired = true,
PasswordBlockSimple = true,
PasswordRequiredToUnlockFromIdle = true,
PasswordMinutesOfInactivityBeforeLock = 5,
PasswordExpirationDays = 6,
PasswordMinimumLength = 5,
PasswordMinimumCharacterSetCount = 0,
PasswordRequiredType = RequiredPasswordType.Alphanumeric,
PasswordPreviousPasswordBlockCount = 2,
RequireHealthyDeviceReport = true,
OsMinimumVersion = "Os Minimum Version value",
OsMaximumVersion = "Os Maximum Version value",
MobileOsMinimumVersion = "Mobile Os Minimum Version value",
MobileOsMaximumVersion = "Mobile Os Maximum Version value",
EarlyLaunchAntiMalwareDriverEnabled = true,
BitLockerEnabled = true,
SecureBootEnabled = true,
CodeIntegrityEnabled = true,
StorageRequireEncryption = true,
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.DeviceManagement.DeviceCompliancePolicies.PostAsync(requestBody);
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
Windows10CompliancePolicy deviceCompliancePolicy = new Windows10CompliancePolicy();
deviceCompliancePolicy.setOdataType("#microsoft.graph.windows10CompliancePolicy");
deviceCompliancePolicy.setDescription("Description value");
deviceCompliancePolicy.setDisplayName("Display Name value");
deviceCompliancePolicy.setVersion(7);
deviceCompliancePolicy.setPasswordRequired(true);
deviceCompliancePolicy.setPasswordBlockSimple(true);
deviceCompliancePolicy.setPasswordRequiredToUnlockFromIdle(true);
deviceCompliancePolicy.setPasswordMinutesOfInactivityBeforeLock(5);
deviceCompliancePolicy.setPasswordExpirationDays(6);
deviceCompliancePolicy.setPasswordMinimumLength(5);
deviceCompliancePolicy.setPasswordMinimumCharacterSetCount(0);
deviceCompliancePolicy.setPasswordRequiredType(RequiredPasswordType.Alphanumeric);
deviceCompliancePolicy.setPasswordPreviousPasswordBlockCount(2);
deviceCompliancePolicy.setRequireHealthyDeviceReport(true);
deviceCompliancePolicy.setOsMinimumVersion("Os Minimum Version value");
deviceCompliancePolicy.setOsMaximumVersion("Os Maximum Version value");
deviceCompliancePolicy.setMobileOsMinimumVersion("Mobile Os Minimum Version value");
deviceCompliancePolicy.setMobileOsMaximumVersion("Mobile Os Maximum Version value");
deviceCompliancePolicy.setEarlyLaunchAntiMalwareDriverEnabled(true);
deviceCompliancePolicy.setBitLockerEnabled(true);
deviceCompliancePolicy.setSecureBootEnabled(true);
deviceCompliancePolicy.setCodeIntegrityEnabled(true);
deviceCompliancePolicy.setStorageRequireEncryption(true);
DeviceCompliancePolicy result = graphClient.deviceManagement().deviceCompliancePolicies().post(deviceCompliancePolicy);
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\Windows10CompliancePolicy;
use Microsoft\Graph\Generated\Models\RequiredPasswordType;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new Windows10CompliancePolicy();
$requestBody->setOdataType('#microsoft.graph.windows10CompliancePolicy');
$requestBody->setDescription('Description value');
$requestBody->setDisplayName('Display Name value');
$requestBody->setVersion(7);
$requestBody->setPasswordRequired(true);
$requestBody->setPasswordBlockSimple(true);
$requestBody->setPasswordRequiredToUnlockFromIdle(true);
$requestBody->setPasswordMinutesOfInactivityBeforeLock(5);
$requestBody->setPasswordExpirationDays(6);
$requestBody->setPasswordMinimumLength(5);
$requestBody->setPasswordMinimumCharacterSetCount(0);
$requestBody->setPasswordRequiredType(new RequiredPasswordType('alphanumeric'));
$requestBody->setPasswordPreviousPasswordBlockCount(2);
$requestBody->setRequireHealthyDeviceReport(true);
$requestBody->setOsMinimumVersion('Os Minimum Version value');
$requestBody->setOsMaximumVersion('Os Maximum Version value');
$requestBody->setMobileOsMinimumVersion('Mobile Os Minimum Version value');
$requestBody->setMobileOsMaximumVersion('Mobile Os Maximum Version value');
$requestBody->setEarlyLaunchAntiMalwareDriverEnabled(true);
$requestBody->setBitLockerEnabled(true);
$requestBody->setSecureBootEnabled(true);
$requestBody->setCodeIntegrityEnabled(true);
$requestBody->setStorageRequireEncryption(true);
$result = $graphServiceClient->deviceManagement()->deviceCompliancePolicies()->post($requestBody)->wait();
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: 1126
{
"@odata.type": "#microsoft.graph.windows10CompliancePolicy",
"id": "2919ae62-ae62-2919-62ae-192962ae1929",
"createdDateTime": "2017-01-01T00:02:43.5775965-08:00",
"description": "Description value",
"lastModifiedDateTime": "2017-01-01T00:00:35.1329464-08:00",
"displayName": "Display Name value",
"version": 7,
"passwordRequired": true,
"passwordBlockSimple": true,
"passwordRequiredToUnlockFromIdle": true,
"passwordMinutesOfInactivityBeforeLock": 5,
"passwordExpirationDays": 6,
"passwordMinimumLength": 5,
"passwordMinimumCharacterSetCount": 0,
"passwordRequiredType": "alphanumeric",
"passwordPreviousPasswordBlockCount": 2,
"requireHealthyDeviceReport": true,
"osMinimumVersion": "Os Minimum Version value",
"osMaximumVersion": "Os Maximum Version value",
"mobileOsMinimumVersion": "Mobile Os Minimum Version value",
"mobileOsMaximumVersion": "Mobile Os Maximum Version value",
"earlyLaunchAntiMalwareDriverEnabled": true,
"bitLockerEnabled": true,
"secureBootEnabled": true,
"codeIntegrityEnabled": true,
"storageRequireEncryption": true
}