Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,540 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
To assign Windows Autopilot Deployment Profile to one group I use the following code.
Request Body:
{
"target": {
"@odata.type": "#microsoft.graph.groupAssignmentTarget",
"groupId": "<The group id>"
}
}
But how do I assign it to multiple groups? I have tested the following code (Based on ide from @Crystal-MSFT answer in an earlier question) but it don't work.
Request Body:
[
{
"target": {
"@odata.type": "#microsoft.graph.groupAssignmentTarget",
"groupId": "<The group id>"
}
},
{
"target": {
"@odata.type": "#microsoft.graph.groupAssignmentTarget",
"groupId": "<The group id>"
}
}
]
How do I assign it to multiple groups?
Br
Johan
I managed to solve it in the following way:
# Loop through the groupIds and assign the profile to each group
foreach ($groupId in $groupIds) {
$assignmentBody = @{
target = @{
"@odata.type" = "#microsoft.graph.groupAssignmentTarget"
groupId = $groupId
}
} | ConvertTo-Json
# Make the API call to assign the profile to the current group
}