// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new IosCompliancePolicy
{
OdataType = "#microsoft.graph.iosCompliancePolicy",
Description = "Description value",
DisplayName = "Display Name value",
Version = 7,
PasscodeBlockSimple = true,
PasscodeExpirationDays = 6,
PasscodeMinimumLength = 5,
PasscodeMinutesOfInactivityBeforeLock = 5,
PasscodePreviousPasscodeBlockCount = 2,
PasscodeMinimumCharacterSetCount = 0,
PasscodeRequiredType = RequiredPasswordType.Alphanumeric,
PasscodeRequired = true,
OsMinimumVersion = "Os Minimum Version value",
OsMaximumVersion = "Os Maximum Version value",
SecurityBlockJailbrokenDevices = true,
DeviceThreatProtectionEnabled = true,
DeviceThreatProtectionRequiredSecurityLevel = DeviceThreatProtectionLevel.Secured,
ManagedEmailProfileRequired = 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);
IosCompliancePolicy deviceCompliancePolicy = new IosCompliancePolicy();
deviceCompliancePolicy.setOdataType("#microsoft.graph.iosCompliancePolicy");
deviceCompliancePolicy.setDescription("Description value");
deviceCompliancePolicy.setDisplayName("Display Name value");
deviceCompliancePolicy.setVersion(7);
deviceCompliancePolicy.setPasscodeBlockSimple(true);
deviceCompliancePolicy.setPasscodeExpirationDays(6);
deviceCompliancePolicy.setPasscodeMinimumLength(5);
deviceCompliancePolicy.setPasscodeMinutesOfInactivityBeforeLock(5);
deviceCompliancePolicy.setPasscodePreviousPasscodeBlockCount(2);
deviceCompliancePolicy.setPasscodeMinimumCharacterSetCount(0);
deviceCompliancePolicy.setPasscodeRequiredType(RequiredPasswordType.Alphanumeric);
deviceCompliancePolicy.setPasscodeRequired(true);
deviceCompliancePolicy.setOsMinimumVersion("Os Minimum Version value");
deviceCompliancePolicy.setOsMaximumVersion("Os Maximum Version value");
deviceCompliancePolicy.setSecurityBlockJailbrokenDevices(true);
deviceCompliancePolicy.setDeviceThreatProtectionEnabled(true);
deviceCompliancePolicy.setDeviceThreatProtectionRequiredSecurityLevel(DeviceThreatProtectionLevel.Secured);
deviceCompliancePolicy.setManagedEmailProfileRequired(true);
DeviceCompliancePolicy result = graphClient.deviceManagement().deviceCompliancePolicies().post(deviceCompliancePolicy);
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\IosCompliancePolicy;
use Microsoft\Graph\Generated\Models\RequiredPasswordType;
use Microsoft\Graph\Generated\Models\DeviceThreatProtectionLevel;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new IosCompliancePolicy();
$requestBody->setOdataType('#microsoft.graph.iosCompliancePolicy');
$requestBody->setDescription('Description value');
$requestBody->setDisplayName('Display Name value');
$requestBody->setVersion(7);
$requestBody->setPasscodeBlockSimple(true);
$requestBody->setPasscodeExpirationDays(6);
$requestBody->setPasscodeMinimumLength(5);
$requestBody->setPasscodeMinutesOfInactivityBeforeLock(5);
$requestBody->setPasscodePreviousPasscodeBlockCount(2);
$requestBody->setPasscodeMinimumCharacterSetCount(0);
$requestBody->setPasscodeRequiredType(new RequiredPasswordType('alphanumeric'));
$requestBody->setPasscodeRequired(true);
$requestBody->setOsMinimumVersion('Os Minimum Version value');
$requestBody->setOsMaximumVersion('Os Maximum Version value');
$requestBody->setSecurityBlockJailbrokenDevices(true);
$requestBody->setDeviceThreatProtectionEnabled(true);
$requestBody->setDeviceThreatProtectionRequiredSecurityLevel(new DeviceThreatProtectionLevel('secured'));
$requestBody->setManagedEmailProfileRequired(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.