File tree Expand file tree Collapse file tree 2 files changed +15
-4
lines changed
Entrypoints/HTTP Functions/Endpoint/Applications Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ function Invoke-ExecAssignApp {
2020 $AppType = $Request.Query.AppType ?? $Request.Body.AppType
2121 $GroupNamesRaw = $Request.Query.GroupNames ?? $Request.Body.GroupNames
2222 $GroupIdsRaw = $Request.Query.GroupIds ?? $Request.Body.GroupIds
23- $AssignmentMode = $Request.Query.AssignmentMode ?? $Request . Body.AssignmentMode
23+ $AssignmentMode = $Request.Body.assignmentMode
2424
2525 $Intent = if ([string ]::IsNullOrWhiteSpace($Intent )) { ' Required' } else { $Intent }
2626
@@ -58,7 +58,7 @@ function Invoke-ExecAssignApp {
5858 # Try to get the application type if not provided. Mostly just useful for ppl using the API that dont know the application type.
5959 if (-not $AppType ) {
6060 try {
61- $AppMetadata = New-GraphGetRequest - uri " https://graph.microsoft.com/beta/deviceAppManagement/mobileApps/$appFilter ? `$ select=id,@odata.type " - tenantid $TenantFilter
61+ $AppMetadata = New-GraphGetRequest - uri " https://graph.microsoft.com/beta/deviceAppManagement/mobileApps/$appFilter " - tenantid $TenantFilter
6262 $odataType = $AppMetadata .' @odata.type'
6363 if ($odataType ) {
6464 $AppType = ($odataType -replace ' #microsoft.graph.' , ' ' ) -replace ' App$'
Original file line number Diff line number Diff line change @@ -128,8 +128,18 @@ function Set-CIPPAssignedApplication {
128128 # Deduplicate current assignments so the new ones override existing ones
129129 if ($ExistingAssignments ) {
130130 $ExistingAssignments = $ExistingAssignments | ForEach-Object {
131- if ($_.target.groupId -notin $MobileAppAssignment.target.groupId ) {
132- $_
131+ $ExistingAssignment = $_
132+ switch ($ExistingAssignment.target .' @odata.type' ) {
133+ ' #microsoft.graph.groupAssignmentTarget' {
134+ if ($ExistingAssignment.target.groupId -notin $MobileAppAssignment.target.groupId ) {
135+ $ExistingAssignment
136+ }
137+ }
138+ default {
139+ if ($ExistingAssignment.target .' @odata.type' -notin $MobileAppAssignment.target .' @odata.type' ) {
140+ $ExistingAssignment
141+ }
142+ }
133143 }
134144 }
135145 }
@@ -164,6 +174,7 @@ function Set-CIPPAssignedApplication {
164174 }
165175 if ($PSCmdlet.ShouldProcess ($GroupName , " Assigning Application $ApplicationId " )) {
166176 Start-Sleep - Seconds 1
177+ # Write-Information (ConvertTo-Json $DefaultAssignmentObject -Depth 10)
167178 $null = New-GraphPOSTRequest - uri " https://graph.microsoft.com/beta/deviceAppManagement/mobileApps/$ ( $ApplicationId ) /assign" - tenantid $TenantFilter - type POST - body ($DefaultAssignmentObject | ConvertTo-Json - Compress - Depth 10 )
168179 Write-LogMessage - headers $Headers - API $APIName - message " Assigned Application $ApplicationId to $ ( $GroupName ) " - Sev ' Info' - tenant $TenantFilter
169180 }
You can’t perform that action at this time.
0 commit comments