Create macOSGeneralDeviceConfiguration
Article 08/01/2024
13 contributors
Feedback
In this article
Namespace: microsoft.graph
Note: The Microsoft Graph API for Intune requires an active Intune license for the tenant.
Create a new macOSGeneralDeviceConfiguration 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
Delegated (personal Microsoft account)
Not supported.
Application
DeviceManagementConfiguration.ReadWrite.All
HTTP Request
POST /deviceManagement/deviceConfigurations
Request body
In the request body, supply a JSON representation for the macOSGeneralDeviceConfiguration object.
The following table shows the properties that are required when you create the macOSGeneralDeviceConfiguration.
Property
Type
Description
id
String
Key of the entity. Inherited from deviceConfiguration
lastModifiedDateTime
DateTimeOffset
DateTime the object was last modified. Inherited from deviceConfiguration
createdDateTime
DateTimeOffset
DateTime the object was created. Inherited from deviceConfiguration
description
String
Admin provided description of the Device Configuration. Inherited from deviceConfiguration
displayName
String
Admin provided name of the device configuration. Inherited from deviceConfiguration
version
Int32
Version of the device configuration. Inherited from deviceConfiguration
compliantAppsList
appListItem collection
List of apps in the compliance (either allow list or block list, controlled by CompliantAppListType). This collection can contain a maximum of 10000 elements.
compliantAppListType
appListType
List that is in the CompliantAppsList. Possible values are: none
, appsInListCompliant
, appsNotInListCompliant
.
emailInDomainSuffixes
String collection
An email address lacking a suffix that matches any of these strings will be considered out-of-domain.
passwordBlockSimple
Boolean
Block simple passwords.
passwordExpirationDays
Int32
Number of days before the password expires.
passwordMinimumCharacterSetCount
Int32
Number of character sets a password must contain. Valid values 0 to 4
passwordMinimumLength
Int32
Minimum length of passwords.
passwordMinutesOfInactivityBeforeLock
Int32
Minutes of inactivity required before a password is required.
passwordMinutesOfInactivityBeforeScreenTimeout
Int32
Minutes of inactivity required before the screen times out.
passwordPreviousPasswordBlockCount
Int32
Number of previous passwords to block.
passwordRequiredType
requiredPasswordType
Type of password that is required. Possible values are: deviceDefault
, alphanumeric
, numeric
.
passwordRequired
Boolean
Whether or not to require a password.
Response
If successful, this method returns a 201 Created
response code and a macOSGeneralDeviceConfiguration object in the response body.
Example
Request
Here is an example of the request.
POST https://graph.microsoft.com/v1.0/deviceManagement/deviceConfigurations
Content-type: application/json
Content-length: 906
{
"@odata.type": "#microsoft.graph.macOSGeneralDeviceConfiguration",
"description": "Description value",
"displayName": "Display Name value",
"version": 7,
"compliantAppsList": [
{
"@odata.type": "microsoft.graph.appListItem",
"name": "Name value",
"publisher": "Publisher value",
"appStoreUrl": "https://example.com/appStoreUrl/",
"appId": "App Id value"
}
],
"compliantAppListType": "appsInListCompliant",
"emailInDomainSuffixes": [
"Email In Domain Suffixes value"
],
"passwordBlockSimple": true,
"passwordExpirationDays": 6,
"passwordMinimumCharacterSetCount": 0,
"passwordMinimumLength": 5,
"passwordMinutesOfInactivityBeforeLock": 5,
"passwordMinutesOfInactivityBeforeScreenTimeout": 14,
"passwordPreviousPasswordBlockCount": 2,
"passwordRequiredType": "alphanumeric",
"passwordRequired": true
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new MacOSGeneralDeviceConfiguration
{
OdataType = "#microsoft.graph.macOSGeneralDeviceConfiguration",
Description = "Description value",
DisplayName = "Display Name value",
Version = 7,
CompliantAppsList = new List<AppListItem>
{
new AppListItem
{
OdataType = "microsoft.graph.appListItem",
Name = "Name value",
Publisher = "Publisher value",
AppStoreUrl = "https://example.com/appStoreUrl/",
AppId = "App Id value",
},
},
CompliantAppListType = AppListType.AppsInListCompliant,
EmailInDomainSuffixes = new List<string>
{
"Email In Domain Suffixes value",
},
PasswordBlockSimple = true,
PasswordExpirationDays = 6,
PasswordMinimumCharacterSetCount = 0,
PasswordMinimumLength = 5,
PasswordMinutesOfInactivityBeforeLock = 5,
PasswordMinutesOfInactivityBeforeScreenTimeout = 14,
PasswordPreviousPasswordBlockCount = 2,
PasswordRequiredType = RequiredPasswordType.Alphanumeric,
PasswordRequired = 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.DeviceConfigurations.PostAsync(requestBody);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
mgc device-management device-configurations create --body '{\
"@odata.type": "#microsoft.graph.macOSGeneralDeviceConfiguration",\
"description": "Description value",\
"displayName": "Display Name value",\
"version": 7,\
"compliantAppsList": [\
{\
"@odata.type": "microsoft.graph.appListItem",\
"name": "Name value",\
"publisher": "Publisher value",\
"appStoreUrl": "https://example.com/appStoreUrl/",\
"appId": "App Id value"\
}\
],\
"compliantAppListType": "appsInListCompliant",\
"emailInDomainSuffixes": [\
"Email In Domain Suffixes value"\
],\
"passwordBlockSimple": true,\
"passwordExpirationDays": 6,\
"passwordMinimumCharacterSetCount": 0,\
"passwordMinimumLength": 5,\
"passwordMinutesOfInactivityBeforeLock": 5,\
"passwordMinutesOfInactivityBeforeScreenTimeout": 14,\
"passwordPreviousPasswordBlockCount": 2,\
"passwordRequiredType": "alphanumeric",\
"passwordRequired": true\
}\
'
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewDeviceConfiguration()
description := "Description value"
requestBody.SetDescription(&description)
displayName := "Display Name value"
requestBody.SetDisplayName(&displayName)
version := int32(7)
requestBody.SetVersion(&version)
appListItem := graphmodels.NewAppListItem()
name := "Name value"
appListItem.SetName(&name)
publisher := "Publisher value"
appListItem.SetPublisher(&publisher)
appStoreUrl := "https://example.com/appStoreUrl/"
appListItem.SetAppStoreUrl(&appStoreUrl)
appId := "App Id value"
appListItem.SetAppId(&appId)
compliantAppsList := []graphmodels.AppListItemable {
appListItem,
}
requestBody.SetCompliantAppsList(compliantAppsList)
compliantAppListType := graphmodels.APPSINLISTCOMPLIANT_APPLISTTYPE
requestBody.SetCompliantAppListType(&compliantAppListType)
emailInDomainSuffixes := []string {
"Email In Domain Suffixes value",
}
requestBody.SetEmailInDomainSuffixes(emailInDomainSuffixes)
passwordBlockSimple := true
requestBody.SetPasswordBlockSimple(&passwordBlockSimple)
passwordExpirationDays := int32(6)
requestBody.SetPasswordExpirationDays(&passwordExpirationDays)
passwordMinimumCharacterSetCount := int32(0)
requestBody.SetPasswordMinimumCharacterSetCount(&passwordMinimumCharacterSetCount)
passwordMinimumLength := int32(5)
requestBody.SetPasswordMinimumLength(&passwordMinimumLength)
passwordMinutesOfInactivityBeforeLock := int32(5)
requestBody.SetPasswordMinutesOfInactivityBeforeLock(&passwordMinutesOfInactivityBeforeLock)
passwordMinutesOfInactivityBeforeScreenTimeout := int32(14)
requestBody.SetPasswordMinutesOfInactivityBeforeScreenTimeout(&passwordMinutesOfInactivityBeforeScreenTimeout)
passwordPreviousPasswordBlockCount := int32(2)
requestBody.SetPasswordPreviousPasswordBlockCount(&passwordPreviousPasswordBlockCount)
passwordRequiredType := graphmodels.ALPHANUMERIC_REQUIREDPASSWORDTYPE
requestBody.SetPasswordRequiredType(&passwordRequiredType)
passwordRequired := true
requestBody.SetPasswordRequired(&passwordRequired)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
deviceConfigurations, err := graphClient.DeviceManagement().DeviceConfigurations().Post(context.Background(), requestBody, nil)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
MacOSGeneralDeviceConfiguration deviceConfiguration = new MacOSGeneralDeviceConfiguration();
deviceConfiguration.setOdataType("#microsoft.graph.macOSGeneralDeviceConfiguration");
deviceConfiguration.setDescription("Description value");
deviceConfiguration.setDisplayName("Display Name value");
deviceConfiguration.setVersion(7);
LinkedList<AppListItem> compliantAppsList = new LinkedList<AppListItem>();
AppListItem appListItem = new AppListItem();
appListItem.setOdataType("microsoft.graph.appListItem");
appListItem.setName("Name value");
appListItem.setPublisher("Publisher value");
appListItem.setAppStoreUrl("https://example.com/appStoreUrl/");
appListItem.setAppId("App Id value");
compliantAppsList.add(appListItem);
deviceConfiguration.setCompliantAppsList(compliantAppsList);
deviceConfiguration.setCompliantAppListType(AppListType.AppsInListCompliant);
LinkedList<String> emailInDomainSuffixes = new LinkedList<String>();
emailInDomainSuffixes.add("Email In Domain Suffixes value");
deviceConfiguration.setEmailInDomainSuffixes(emailInDomainSuffixes);
deviceConfiguration.setPasswordBlockSimple(true);
deviceConfiguration.setPasswordExpirationDays(6);
deviceConfiguration.setPasswordMinimumCharacterSetCount(0);
deviceConfiguration.setPasswordMinimumLength(5);
deviceConfiguration.setPasswordMinutesOfInactivityBeforeLock(5);
deviceConfiguration.setPasswordMinutesOfInactivityBeforeScreenTimeout(14);
deviceConfiguration.setPasswordPreviousPasswordBlockCount(2);
deviceConfiguration.setPasswordRequiredType(RequiredPasswordType.Alphanumeric);
deviceConfiguration.setPasswordRequired(true);
DeviceConfiguration result = graphClient.deviceManagement().deviceConfigurations().post(deviceConfiguration);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
const options = {
authProvider,
};
const client = Client.init(options);
const deviceConfiguration = {
'@odata.type': '#microsoft.graph.macOSGeneralDeviceConfiguration',
description: 'Description value',
displayName: 'Display Name value',
version: 7,
compliantAppsList: [
{
'@odata.type': 'microsoft.graph.appListItem',
name: 'Name value',
publisher: 'Publisher value',
appStoreUrl: 'https://example.com/appStoreUrl/',
appId: 'App Id value'
}
],
compliantAppListType: 'appsInListCompliant',
emailInDomainSuffixes: [
'Email In Domain Suffixes value'
],
passwordBlockSimple: true,
passwordExpirationDays: 6,
passwordMinimumCharacterSetCount: 0,
passwordMinimumLength: 5,
passwordMinutesOfInactivityBeforeLock: 5,
passwordMinutesOfInactivityBeforeScreenTimeout: 14,
passwordPreviousPasswordBlockCount: 2,
passwordRequiredType: 'alphanumeric',
passwordRequired: true
};
await client.api('/deviceManagement/deviceConfigurations')
.post(deviceConfiguration);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\MacOSGeneralDeviceConfiguration;
use Microsoft\Graph\Generated\Models\AppListItem;
use Microsoft\Graph\Generated\Models\AppListType;
use Microsoft\Graph\Generated\Models\RequiredPasswordType;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new MacOSGeneralDeviceConfiguration();
$requestBody->setOdataType('#microsoft.graph.macOSGeneralDeviceConfiguration');
$requestBody->setDescription('Description value');
$requestBody->setDisplayName('Display Name value');
$requestBody->setVersion(7);
$compliantAppsListAppListItem1 = new AppListItem();
$compliantAppsListAppListItem1->setOdataType('microsoft.graph.appListItem');
$compliantAppsListAppListItem1->setName('Name value');
$compliantAppsListAppListItem1->setPublisher('Publisher value');
$compliantAppsListAppListItem1->setAppStoreUrl('https://example.com/appStoreUrl/');
$compliantAppsListAppListItem1->setAppId('App Id value');
$compliantAppsListArray []= $compliantAppsListAppListItem1;
$requestBody->setCompliantAppsList($compliantAppsListArray);
$requestBody->setCompliantAppListType(new AppListType('appsInListCompliant'));
$requestBody->setEmailInDomainSuffixes(['Email In Domain Suffixes value', ]);
$requestBody->setPasswordBlockSimple(true);
$requestBody->setPasswordExpirationDays(6);
$requestBody->setPasswordMinimumCharacterSetCount(0);
$requestBody->setPasswordMinimumLength(5);
$requestBody->setPasswordMinutesOfInactivityBeforeLock(5);
$requestBody->setPasswordMinutesOfInactivityBeforeScreenTimeout(14);
$requestBody->setPasswordPreviousPasswordBlockCount(2);
$requestBody->setPasswordRequiredType(new RequiredPasswordType('alphanumeric'));
$requestBody->setPasswordRequired(true);
$result = $graphServiceClient->deviceManagement()->deviceConfigurations()->post($requestBody)->wait();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
Import-Module Microsoft.Graph.DeviceManagement
$params = @{
"@odata.type" = "#microsoft.graph.macOSGeneralDeviceConfiguration"
description = "Description value"
displayName = "Display Name value"
version = 7
compliantAppsList = @(
@{
"@odata.type" = "microsoft.graph.appListItem"
name = "Name value"
publisher = "Publisher value"
appStoreUrl = "https://example.com/appStoreUrl/"
appId = "App Id value"
}
)
compliantAppListType = "appsInListCompliant"
emailInDomainSuffixes = @(
"Email In Domain Suffixes value"
)
passwordBlockSimple = $true
passwordExpirationDays =
passwordMinimumCharacterSetCount =
passwordMinimumLength =
passwordMinutesOfInactivityBeforeLock =
passwordMinutesOfInactivityBeforeScreenTimeout =
passwordPreviousPasswordBlockCount =
passwordRequiredType = "alphanumeric"
passwordRequired = $true
}
New-MgDeviceManagementDeviceConfiguration -BodyParameter $params
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.mac_o_s_general_device_configuration import MacOSGeneralDeviceConfiguration
from msgraph.generated.models.app_list_item import AppListItem
from msgraph.generated.models.app_list_type import AppListType
from msgraph.generated.models.required_password_type import RequiredPasswordType
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = MacOSGeneralDeviceConfiguration(
odata_type = "#microsoft.graph.macOSGeneralDeviceConfiguration",
description = "Description value",
display_name = "Display Name value",
version = 7,
compliant_apps_list = [
AppListItem(
odata_type = "microsoft.graph.appListItem",
name = "Name value",
publisher = "Publisher value",
app_store_url = "https://example.com/appStoreUrl/",
app_id = "App Id value",
),
],
compliant_app_list_type = AppListType.AppsInListCompliant,
email_in_domain_suffixes = [
"Email In Domain Suffixes value",
],
password_block_simple = True,
password_expiration_days = 6,
password_minimum_character_set_count = 0,
password_minimum_length = 5,
password_minutes_of_inactivity_before_lock = 5,
password_minutes_of_inactivity_before_screen_timeout = 14,
password_previous_password_block_count = 2,
password_required_type = RequiredPasswordType.Alphanumeric,
password_required = True,
)
result = await graph_client.device_management.device_configurations.post(request_body)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
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: 1078
{
"@odata.type": "#microsoft.graph.macOSGeneralDeviceConfiguration",
"id": "dc356aee-6aee-dc35-ee6a-35dcee6a35dc",
"lastModifiedDateTime": "2017-01-01T00:00:35.1329464-08:00",
"createdDateTime": "2017-01-01T00:02:43.5775965-08:00",
"description": "Description value",
"displayName": "Display Name value",
"version": 7,
"compliantAppsList": [
{
"@odata.type": "microsoft.graph.appListItem",
"name": "Name value",
"publisher": "Publisher value",
"appStoreUrl": "https://example.com/appStoreUrl/",
"appId": "App Id value"
}
],
"compliantAppListType": "appsInListCompliant",
"emailInDomainSuffixes": [
"Email In Domain Suffixes value"
],
"passwordBlockSimple": true,
"passwordExpirationDays": 6,
"passwordMinimumCharacterSetCount": 0,
"passwordMinimumLength": 5,
"passwordMinutesOfInactivityBeforeLock": 5,
"passwordMinutesOfInactivityBeforeScreenTimeout": 14,
"passwordPreviousPasswordBlockCount": 2,
"passwordRequiredType": "alphanumeric",
"passwordRequired": true
}