// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.DeviceManagement.DeviceEnrollmentConfigurations.Item.Assign;
using Microsoft.Graph.Models;
var requestBody = new AssignPostRequestBody
{
EnrollmentConfigurationAssignments = new List<EnrollmentConfigurationAssignment>
{
new EnrollmentConfigurationAssignment
{
OdataType = "#microsoft.graph.enrollmentConfigurationAssignment",
Id = "705b021c-021c-705b-1c02-5b701c025b70",
Target = new ConfigurationManagerCollectionAssignmentTarget
{
OdataType = "microsoft.graph.configurationManagerCollectionAssignmentTarget",
CollectionId = "Collection Id value",
},
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
await graphClient.DeviceManagement.DeviceEnrollmentConfigurations["{deviceEnrollmentConfiguration-id}"].Assign.PostAsync(requestBody);
// 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"
graphdevicemanagement "github.com/microsoftgraph/msgraph-sdk-go/devicemanagement"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphdevicemanagement.NewAssignPostRequestBody()
enrollmentConfigurationAssignment := graphmodels.NewEnrollmentConfigurationAssignment()
id := "705b021c-021c-705b-1c02-5b701c025b70"
enrollmentConfigurationAssignment.SetId(&id)
target := graphmodels.NewConfigurationManagerCollectionAssignmentTarget()
collectionId := "Collection Id value"
target.SetCollectionId(&collectionId)
enrollmentConfigurationAssignment.SetTarget(target)
enrollmentConfigurationAssignments := []graphmodels.EnrollmentConfigurationAssignmentable {
enrollmentConfigurationAssignment,
}
requestBody.SetEnrollmentConfigurationAssignments(enrollmentConfigurationAssignments)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
graphClient.DeviceManagement().DeviceEnrollmentConfigurations().ByDeviceEnrollmentConfigurationId("deviceEnrollmentConfiguration-id").Assign().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
com.microsoft.graph.devicemanagement.deviceenrollmentconfigurations.item.assign.AssignPostRequestBody assignPostRequestBody = new com.microsoft.graph.devicemanagement.deviceenrollmentconfigurations.item.assign.AssignPostRequestBody();
LinkedList<EnrollmentConfigurationAssignment> enrollmentConfigurationAssignments = new LinkedList<EnrollmentConfigurationAssignment>();
EnrollmentConfigurationAssignment enrollmentConfigurationAssignment = new EnrollmentConfigurationAssignment();
enrollmentConfigurationAssignment.setOdataType("#microsoft.graph.enrollmentConfigurationAssignment");
enrollmentConfigurationAssignment.setId("705b021c-021c-705b-1c02-5b701c025b70");
ConfigurationManagerCollectionAssignmentTarget target = new ConfigurationManagerCollectionAssignmentTarget();
target.setOdataType("microsoft.graph.configurationManagerCollectionAssignmentTarget");
target.setCollectionId("Collection Id value");
enrollmentConfigurationAssignment.setTarget(target);
enrollmentConfigurationAssignments.add(enrollmentConfigurationAssignment);
assignPostRequestBody.setEnrollmentConfigurationAssignments(enrollmentConfigurationAssignments);
graphClient.deviceManagement().deviceEnrollmentConfigurations().byDeviceEnrollmentConfigurationId("{deviceEnrollmentConfiguration-id}").assign().post(assignPostRequestBody);
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\DeviceManagement\DeviceEnrollmentConfigurations\Item\Assign\AssignPostRequestBody;
use Microsoft\Graph\Generated\Models\EnrollmentConfigurationAssignment;
use Microsoft\Graph\Generated\Models\ConfigurationManagerCollectionAssignmentTarget;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new AssignPostRequestBody();
$enrollmentConfigurationAssignmentsEnrollmentConfigurationAssignment1 = new EnrollmentConfigurationAssignment();
$enrollmentConfigurationAssignmentsEnrollmentConfigurationAssignment1->setOdataType('#microsoft.graph.enrollmentConfigurationAssignment');
$enrollmentConfigurationAssignmentsEnrollmentConfigurationAssignment1->setId('705b021c-021c-705b-1c02-5b701c025b70');
$enrollmentConfigurationAssignmentsEnrollmentConfigurationAssignment1Target = new ConfigurationManagerCollectionAssignmentTarget();
$enrollmentConfigurationAssignmentsEnrollmentConfigurationAssignment1Target->setOdataType('microsoft.graph.configurationManagerCollectionAssignmentTarget');
$enrollmentConfigurationAssignmentsEnrollmentConfigurationAssignment1Target->setCollectionId('Collection Id value');
$enrollmentConfigurationAssignmentsEnrollmentConfigurationAssignment1->setTarget($enrollmentConfigurationAssignmentsEnrollmentConfigurationAssignment1Target);
$enrollmentConfigurationAssignmentsArray []= $enrollmentConfigurationAssignmentsEnrollmentConfigurationAssignment1;
$requestBody->setEnrollmentConfigurationAssignments($enrollmentConfigurationAssignmentsArray);
$graphServiceClient->deviceManagement()->deviceEnrollmentConfigurations()->byDeviceEnrollmentConfigurationId('deviceEnrollmentConfiguration-id')->assign()->post($requestBody)->wait();
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.devicemanagement.deviceenrollmentconfigurations.item.assign.assign_post_request_body import AssignPostRequestBody
from msgraph.generated.models.enrollment_configuration_assignment import EnrollmentConfigurationAssignment
from msgraph.generated.models.configuration_manager_collection_assignment_target import ConfigurationManagerCollectionAssignmentTarget
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = AssignPostRequestBody(
enrollment_configuration_assignments = [
EnrollmentConfigurationAssignment(
odata_type = "#microsoft.graph.enrollmentConfigurationAssignment",
id = "705b021c-021c-705b-1c02-5b701c025b70",
target = ConfigurationManagerCollectionAssignmentTarget(
odata_type = "microsoft.graph.configurationManagerCollectionAssignmentTarget",
collection_id = "Collection Id value",
),
),
],
)
await graph_client.device_management.device_enrollment_configurations.by_device_enrollment_configuration_id('deviceEnrollmentConfiguration-id').assign.post(request_body)
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.