Actualizar macOSCompliancePolicy
Artículo 12/04/2023
12 colaboradores
Comentarios
En este artículo
Espacio de nombres: microsoft.graph
Nota: la API de Microsoft Graph para Intune requiere una licencia activa de Intune para el espacio empresarial.
Actualice las propiedades de un objeto macOSCompliancePolicy .
Esta API está disponible en las siguientes implementaciones nacionales de nube .
Servicio global
Gobierno de EE. UU. L4
Us Government L5 (DOD)
China operada por 21Vianet
✅
✅
✅
✅
Permisos
Se requiere uno de los siguientes permisos para llamar a esta API. Para obtener más información, incluido cómo elegir permisos, vea Permisos .
Tipo de permiso
Permisos (de menos a más privilegiados)
Delegado (cuenta profesional o educativa)
DeviceManagementConfiguration.ReadWrite.All
Delegado (cuenta personal de Microsoft)
No admitida.
Aplicación
DeviceManagementConfiguration.ReadWrite.All
Solicitud HTTP
PATCH /deviceManagement/deviceCompliancePolicies/{deviceCompliancePolicyId}
Cuerpo de la solicitud
En el cuerpo de la solicitud, especifique una representación JSON del objeto macOSCompliancePolicy .
En la tabla siguiente se muestran las propiedades necesarias para crear el objeto macOSCompliancePolicy .
Propiedad
Tipo
Descripción
id
Cadena
Clave de la entidad. Heredado de deviceCompliancePolicy .
createdDateTime
DateTimeOffset
Fecha y hora en la que se creó el objeto. Heredado de deviceCompliancePolicy .
description
Cadena
Descripción proporcionada por el administrador de la configuración del dispositivo. Heredado de deviceCompliancePolicy .
lastModifiedDateTime
DateTimeOffset
Fecha y hora en la que se modificó el objeto por última vez. Heredado de deviceCompliancePolicy .
displayName
Cadena
Nombre proporcionado por el administrador de la configuración del dispositivo. Heredado de deviceCompliancePolicy .
version
Int32
Versión de la configuración del dispositivo. Heredado de deviceCompliancePolicy .
passwordRequired
Booleano
Si quiere requerir o no una contraseña.
passwordBlockSimple
Booleano
Indica si se van a bloquear las contraseñas simples.
passwordExpirationDays
Int32
Número de días antes de que expire la contraseña. Valores válidos de 1 a 65535
passwordMinimumLength
Int32
Longitud mínima de la contraseña. Valores válidos de 4 a 14
passwordMinutesOfInactivityBeforeLock
Int32
Minutos de inactividad antes de que sea necesaria una contraseña.
passwordPreviousPasswordBlockCount
Int32
Número de contraseñas anteriores que bloquear. Valores válidos de 1 a 24.
passwordMinimumCharacterSetCount
Int32
Número de juegos de caracteres necesarios en la contraseña.
passwordRequiredType
requiredPasswordType
Tipo de contraseña necesaria. Los valores posibles son: deviceDefault
, alphanumeric
y numeric
.
osMinimumVersion
Cadena
Versión mínima de MacOS.
osMaximumVersion
Cadena
Versión máxima de MacOS.
systemIntegrityProtectionEnabled
Booleano
Requiere que los dispositivos hayan habilitado la protección de integridad del sistema.
deviceThreatProtectionEnabled
Booleano
Exigir que los dispositivos hayan habilitado la protección contra amenazas de dispositivo.
deviceThreatProtectionRequiredSecurityLevel
deviceThreatProtectionLevel
Exigir que el nivel de riesgo mínimo de Mobile Threat Protection informe del no cumplimiento. Los valores posibles son: unavailable
, secured
, low
, medium
, high
y notSet
.
storageRequireEncryption
Booleano
Exige el cifrado en dispositivos Mac OS.
firewallEnabled
Booleano
Si el firewall debe estar habilitado o no.
firewallBlockAllIncoming
Booleano
Corresponde a la opción "Bloquear todas las conexiones entrantes.
firewallEnableStealthMode
Booleano
Corresponde a "Habilitar modo sigiloso.
Respuesta
Si se ejecuta correctamente, este método devuelve un código de respuesta 200 OK
y un objeto macOSCompliancePolicy actualizado en el cuerpo de la respuesta.
Ejemplo
Solicitud
Aquí tiene un ejemplo de la solicitud.
PATCH https://graph.microsoft.com/v1.0/deviceManagement/deviceCompliancePolicies/{deviceCompliancePolicyId}
Content-type: application/json
Content-length: 849
{
"@odata.type": "#microsoft.graph.macOSCompliancePolicy",
"description": "Description value",
"displayName": "Display Name value",
"version": 7,
"passwordRequired": true,
"passwordBlockSimple": true,
"passwordExpirationDays": 6,
"passwordMinimumLength": 5,
"passwordMinutesOfInactivityBeforeLock": 5,
"passwordPreviousPasswordBlockCount": 2,
"passwordMinimumCharacterSetCount": 0,
"passwordRequiredType": "alphanumeric",
"osMinimumVersion": "Os Minimum Version value",
"osMaximumVersion": "Os Maximum Version value",
"systemIntegrityProtectionEnabled": true,
"deviceThreatProtectionEnabled": true,
"deviceThreatProtectionRequiredSecurityLevel": "secured",
"storageRequireEncryption": true,
"firewallEnabled": true,
"firewallBlockAllIncoming": true,
"firewallEnableStealthMode": true
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new MacOSCompliancePolicy
{
OdataType = "#microsoft.graph.macOSCompliancePolicy",
Description = "Description value",
DisplayName = "Display Name value",
Version = 7,
PasswordRequired = true,
PasswordBlockSimple = true,
PasswordExpirationDays = 6,
PasswordMinimumLength = 5,
PasswordMinutesOfInactivityBeforeLock = 5,
PasswordPreviousPasswordBlockCount = 2,
PasswordMinimumCharacterSetCount = 0,
PasswordRequiredType = RequiredPasswordType.Alphanumeric,
OsMinimumVersion = "Os Minimum Version value",
OsMaximumVersion = "Os Maximum Version value",
SystemIntegrityProtectionEnabled = true,
DeviceThreatProtectionEnabled = true,
DeviceThreatProtectionRequiredSecurityLevel = DeviceThreatProtectionLevel.Secured,
StorageRequireEncryption = true,
FirewallEnabled = true,
FirewallBlockAllIncoming = true,
FirewallEnableStealthMode = true,
};
// To initialize your graphClient, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.DeviceManagement.DeviceCompliancePolicies["{deviceCompliancePolicy-id}"].PatchAsync(requestBody);
Para obtener más información sobre cómo agregar el SDK al proyecto y crear una instancia de authProvider , consulte la documentación del SDK .
mgc device-management device-compliance-policies patch --device-compliance-policy-id {deviceCompliancePolicy-id} --body '{\
"@odata.type": "#microsoft.graph.macOSCompliancePolicy",\
"description": "Description value",\
"displayName": "Display Name value",\
"version": 7,\
"passwordRequired": true,\
"passwordBlockSimple": true,\
"passwordExpirationDays": 6,\
"passwordMinimumLength": 5,\
"passwordMinutesOfInactivityBeforeLock": 5,\
"passwordPreviousPasswordBlockCount": 2,\
"passwordMinimumCharacterSetCount": 0,\
"passwordRequiredType": "alphanumeric",\
"osMinimumVersion": "Os Minimum Version value",\
"osMaximumVersion": "Os Maximum Version value",\
"systemIntegrityProtectionEnabled": true,\
"deviceThreatProtectionEnabled": true,\
"deviceThreatProtectionRequiredSecurityLevel": "secured",\
"storageRequireEncryption": true,\
"firewallEnabled": true,\
"firewallBlockAllIncoming": true,\
"firewallEnableStealthMode": true\
}\
'
Para obtener más información sobre cómo agregar el SDK al proyecto y crear una instancia de authProvider , consulte la documentación del SDK .
// 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.NewDeviceCompliancePolicy()
description := "Description value"
requestBody.SetDescription(&description)
displayName := "Display Name value"
requestBody.SetDisplayName(&displayName)
version := int32(7)
requestBody.SetVersion(&version)
passwordRequired := true
requestBody.SetPasswordRequired(&passwordRequired)
passwordBlockSimple := true
requestBody.SetPasswordBlockSimple(&passwordBlockSimple)
passwordExpirationDays := int32(6)
requestBody.SetPasswordExpirationDays(&passwordExpirationDays)
passwordMinimumLength := int32(5)
requestBody.SetPasswordMinimumLength(&passwordMinimumLength)
passwordMinutesOfInactivityBeforeLock := int32(5)
requestBody.SetPasswordMinutesOfInactivityBeforeLock(&passwordMinutesOfInactivityBeforeLock)
passwordPreviousPasswordBlockCount := int32(2)
requestBody.SetPasswordPreviousPasswordBlockCount(&passwordPreviousPasswordBlockCount)
passwordMinimumCharacterSetCount := int32(0)
requestBody.SetPasswordMinimumCharacterSetCount(&passwordMinimumCharacterSetCount)
passwordRequiredType := graphmodels.ALPHANUMERIC_REQUIREDPASSWORDTYPE
requestBody.SetPasswordRequiredType(&passwordRequiredType)
osMinimumVersion := "Os Minimum Version value"
requestBody.SetOsMinimumVersion(&osMinimumVersion)
osMaximumVersion := "Os Maximum Version value"
requestBody.SetOsMaximumVersion(&osMaximumVersion)
systemIntegrityProtectionEnabled := true
requestBody.SetSystemIntegrityProtectionEnabled(&systemIntegrityProtectionEnabled)
deviceThreatProtectionEnabled := true
requestBody.SetDeviceThreatProtectionEnabled(&deviceThreatProtectionEnabled)
deviceThreatProtectionRequiredSecurityLevel := graphmodels.SECURED_DEVICETHREATPROTECTIONLEVEL
requestBody.SetDeviceThreatProtectionRequiredSecurityLevel(&deviceThreatProtectionRequiredSecurityLevel)
storageRequireEncryption := true
requestBody.SetStorageRequireEncryption(&storageRequireEncryption)
firewallEnabled := true
requestBody.SetFirewallEnabled(&firewallEnabled)
firewallBlockAllIncoming := true
requestBody.SetFirewallBlockAllIncoming(&firewallBlockAllIncoming)
firewallEnableStealthMode := true
requestBody.SetFirewallEnableStealthMode(&firewallEnableStealthMode)
// To initialize your graphClient, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
deviceCompliancePolicies, err := graphClient.DeviceManagement().DeviceCompliancePolicies().ByDeviceCompliancePolicyId("deviceCompliancePolicy-id").Patch(context.Background(), requestBody, nil)
Para obtener más información sobre cómo agregar el SDK al proyecto y crear una instancia de authProvider , consulte la documentación del SDK .
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
MacOSCompliancePolicy deviceCompliancePolicy = new MacOSCompliancePolicy();
deviceCompliancePolicy.setOdataType("#microsoft.graph.macOSCompliancePolicy");
deviceCompliancePolicy.setDescription("Description value");
deviceCompliancePolicy.setDisplayName("Display Name value");
deviceCompliancePolicy.setVersion(7);
deviceCompliancePolicy.setPasswordRequired(true);
deviceCompliancePolicy.setPasswordBlockSimple(true);
deviceCompliancePolicy.setPasswordExpirationDays(6);
deviceCompliancePolicy.setPasswordMinimumLength(5);
deviceCompliancePolicy.setPasswordMinutesOfInactivityBeforeLock(5);
deviceCompliancePolicy.setPasswordPreviousPasswordBlockCount(2);
deviceCompliancePolicy.setPasswordMinimumCharacterSetCount(0);
deviceCompliancePolicy.setPasswordRequiredType(RequiredPasswordType.Alphanumeric);
deviceCompliancePolicy.setOsMinimumVersion("Os Minimum Version value");
deviceCompliancePolicy.setOsMaximumVersion("Os Maximum Version value");
deviceCompliancePolicy.setSystemIntegrityProtectionEnabled(true);
deviceCompliancePolicy.setDeviceThreatProtectionEnabled(true);
deviceCompliancePolicy.setDeviceThreatProtectionRequiredSecurityLevel(DeviceThreatProtectionLevel.Secured);
deviceCompliancePolicy.setStorageRequireEncryption(true);
deviceCompliancePolicy.setFirewallEnabled(true);
deviceCompliancePolicy.setFirewallBlockAllIncoming(true);
deviceCompliancePolicy.setFirewallEnableStealthMode(true);
DeviceCompliancePolicy result = graphClient.deviceManagement().deviceCompliancePolicies().byDeviceCompliancePolicyId("{deviceCompliancePolicy-id}").patch(deviceCompliancePolicy);
Para obtener más información sobre cómo agregar el SDK al proyecto y crear una instancia de authProvider , consulte la documentación del SDK .
const options = {
authProvider,
};
const client = Client.init(options);
const deviceCompliancePolicy = {
'@odata.type': '#microsoft.graph.macOSCompliancePolicy',
description: 'Description value',
displayName: 'Display Name value',
version: 7,
passwordRequired: true,
passwordBlockSimple: true,
passwordExpirationDays: 6,
passwordMinimumLength: 5,
passwordMinutesOfInactivityBeforeLock: 5,
passwordPreviousPasswordBlockCount: 2,
passwordMinimumCharacterSetCount: 0,
passwordRequiredType: 'alphanumeric',
osMinimumVersion: 'Os Minimum Version value',
osMaximumVersion: 'Os Maximum Version value',
systemIntegrityProtectionEnabled: true,
deviceThreatProtectionEnabled: true,
deviceThreatProtectionRequiredSecurityLevel: 'secured',
storageRequireEncryption: true,
firewallEnabled: true,
firewallBlockAllIncoming: true,
firewallEnableStealthMode: true
};
await client.api('/deviceManagement/deviceCompliancePolicies/{deviceCompliancePolicyId}')
.update(deviceCompliancePolicy);
Para obtener más información sobre cómo agregar el SDK al proyecto y crear una instancia de authProvider , consulte la documentación del SDK .
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\MacOSCompliancePolicy;
use Microsoft\Graph\Generated\Models\RequiredPasswordType;
use Microsoft\Graph\Generated\Models\DeviceThreatProtectionLevel;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new MacOSCompliancePolicy();
$requestBody->setOdataType('#microsoft.graph.macOSCompliancePolicy');
$requestBody->setDescription('Description value');
$requestBody->setDisplayName('Display Name value');
$requestBody->setVersion(7);
$requestBody->setPasswordRequired(true);
$requestBody->setPasswordBlockSimple(true);
$requestBody->setPasswordExpirationDays(6);
$requestBody->setPasswordMinimumLength(5);
$requestBody->setPasswordMinutesOfInactivityBeforeLock(5);
$requestBody->setPasswordPreviousPasswordBlockCount(2);
$requestBody->setPasswordMinimumCharacterSetCount(0);
$requestBody->setPasswordRequiredType(new RequiredPasswordType('alphanumeric'));
$requestBody->setOsMinimumVersion('Os Minimum Version value');
$requestBody->setOsMaximumVersion('Os Maximum Version value');
$requestBody->setSystemIntegrityProtectionEnabled(true);
$requestBody->setDeviceThreatProtectionEnabled(true);
$requestBody->setDeviceThreatProtectionRequiredSecurityLevel(new DeviceThreatProtectionLevel('secured'));
$requestBody->setStorageRequireEncryption(true);
$requestBody->setFirewallEnabled(true);
$requestBody->setFirewallBlockAllIncoming(true);
$requestBody->setFirewallEnableStealthMode(true);
$result = $graphServiceClient->deviceManagement()->deviceCompliancePolicies()->byDeviceCompliancePolicyId('deviceCompliancePolicy-id')->patch($requestBody)->wait();
Para obtener más información sobre cómo agregar el SDK al proyecto y crear una instancia de authProvider , consulte la documentación del SDK .
Import-Module Microsoft.Graph.DeviceManagement
$params = @{
"@odata.type" = "#microsoft.graph.macOSCompliancePolicy"
description = "Description value"
displayName = "Display Name value"
version = 7
passwordRequired = $true
passwordBlockSimple = $true
passwordExpirationDays =
passwordMinimumLength =
passwordMinutesOfInactivityBeforeLock =
passwordPreviousPasswordBlockCount =
passwordMinimumCharacterSetCount =
passwordRequiredType = "alphanumeric"
osMinimumVersion = "Os Minimum Version value"
osMaximumVersion = "Os Maximum Version value"
systemIntegrityProtectionEnabled = $true
deviceThreatProtectionEnabled = $true
deviceThreatProtectionRequiredSecurityLevel = "secured"
storageRequireEncryption = $true
firewallEnabled = $true
firewallBlockAllIncoming = $true
firewallEnableStealthMode = $true
}
Update-MgDeviceManagementDeviceCompliancePolicy -DeviceCompliancePolicyId $deviceCompliancePolicyId -BodyParameter $params
Para obtener más información sobre cómo agregar el SDK al proyecto y crear una instancia de authProvider , consulte la documentación del SDK .
# 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_compliance_policy import MacOSCompliancePolicy
from msgraph.generated.models.required_password_type import RequiredPasswordType
from msgraph.generated.models.device_threat_protection_level import DeviceThreatProtectionLevel
# To initialize your graph_client, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = MacOSCompliancePolicy(
odata_type = "#microsoft.graph.macOSCompliancePolicy",
description = "Description value",
display_name = "Display Name value",
version = 7,
password_required = True,
password_block_simple = True,
password_expiration_days = 6,
password_minimum_length = 5,
password_minutes_of_inactivity_before_lock = 5,
password_previous_password_block_count = 2,
password_minimum_character_set_count = 0,
password_required_type = RequiredPasswordType.Alphanumeric,
os_minimum_version = "Os Minimum Version value",
os_maximum_version = "Os Maximum Version value",
system_integrity_protection_enabled = True,
device_threat_protection_enabled = True,
device_threat_protection_required_security_level = DeviceThreatProtectionLevel.Secured,
storage_require_encryption = True,
firewall_enabled = True,
firewall_block_all_incoming = True,
firewall_enable_stealth_mode = True,
)
result = await graph_client.device_management.device_compliance_policies.by_device_compliance_policy_id('deviceCompliancePolicy-id').patch(request_body)
Para obtener más información sobre cómo agregar el SDK al proyecto y crear una instancia de authProvider , consulte la documentación del SDK .
Respuesta
Aquí tiene un ejemplo de la respuesta. Nota: Es posible que el objeto de respuesta que aparezca aquí esté truncado para abreviar. Todas las propiedades se devolverán desde una llamada real.
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 1021
{
"@odata.type": "#microsoft.graph.macOSCompliancePolicy",
"id": "ddbadff3-dff3-ddba-f3df-baddf3dfbadd",
"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,
"passwordExpirationDays": 6,
"passwordMinimumLength": 5,
"passwordMinutesOfInactivityBeforeLock": 5,
"passwordPreviousPasswordBlockCount": 2,
"passwordMinimumCharacterSetCount": 0,
"passwordRequiredType": "alphanumeric",
"osMinimumVersion": "Os Minimum Version value",
"osMaximumVersion": "Os Maximum Version value",
"systemIntegrityProtectionEnabled": true,
"deviceThreatProtectionEnabled": true,
"deviceThreatProtectionRequiredSecurityLevel": "secured",
"storageRequireEncryption": true,
"firewallEnabled": true,
"firewallBlockAllIncoming": true,
"firewallEnableStealthMode": true
}