File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -195,12 +195,17 @@ function Set-CIPPAssignedPolicy {
195195 $FinalAssignments.Add ($newAssignment )
196196 }
197197
198- $assignmentsObject = [PSCustomObject ]@ {
199- # assignments = @($FinalAssignments.ToArray())
200- assignments = @ ($FinalAssignments )
198+ # Determine the assignment property name based on type
199+ $AssignmentPropertyName = switch ($Type ) {
200+ ' deviceHealthScripts' { ' deviceHealthScriptAssignments' }
201+ ' deviceManagementScripts' { ' deviceManagementScriptAssignments' }
202+ ' deviceShellScripts' { ' deviceManagementScriptAssignments' }
203+ default { ' assignments' }
201204 }
202205
203- $AssignJSON = $assignmentsObject | ConvertTo-Json - Depth 10 - Compress
206+ $assignmentsObject = @ { $AssignmentPropertyName = @ ($FinalAssignments ) }
207+
208+ $AssignJSON = ConvertTo-Json - InputObject $assignmentsObject - Depth 10 - Compress
204209 if ($PSCmdlet.ShouldProcess ($GroupName , " Assigning policy $PolicyId " )) {
205210 $uri = " https://graph.microsoft.com/beta/$ ( $PlatformType ) /$Type ('$ ( $PolicyId ) ')/assign"
206211 $null = New-GraphPOSTRequest - uri $uri - tenantid $TenantFilter - type POST - body $AssignJSON
You can’t perform that action at this time.
0 commit comments