You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Added logic to filter included and excluded application IDs in CA policy to ensure only app IDs with a corresponding service principal in the tenant are retained. Also replaced usage of $User with $Headers in log messages for consistency.
Write-LogMessage-Headers $User-API 'Create CA Policy'-message "Already GUID, no need to replace: $_"-Sev 'Debug'
46
+
Write-LogMessage-Headers $Headers-API 'Create CA Policy'-message "Already GUID, no need to replace: $_"-Sev 'Debug'
49
47
$GroupIds.Add($_) # it's a GUID, so we keep it
50
48
} else {
51
49
$groupId= ($groups|Where-Object-Property displayName -EQ$_).id # it's a display name, so we get the group ID
52
50
if ($groupId) {
53
51
foreach ($gidin$groupId) {
54
52
Write-Warning"Replaced group name $_ with ID $gid"
55
-
$null=Write-LogMessage-Headers $User-API 'Create CA Policy'-message "Replaced group name $_ with ID $gid"-Sev 'Debug'
53
+
$null=Write-LogMessage-Headers $Headers-API 'Create CA Policy'-message "Replaced group name $_ with ID $gid"-Sev 'Debug'
56
54
$GroupIds.Add($gid) # add the ID to the list
57
55
}
58
56
} elseif ($CreateGroups) {
@@ -141,6 +139,31 @@ function New-CIPPCAPolicy {
141
139
}
142
140
}
143
141
142
+
#if we have excluded or included applications, we need to remove any appIds that do not have a service principal in the tenant
143
+
144
+
if (($JSONobj.conditions.applications.includeApplications-and$JSONobj.conditions.applications.includeApplications-notcontains'All') -or ($JSONobj.conditions.applications.excludeApplications-and$JSONobj.conditions.applications.excludeApplications-notcontains'All')) {
0 commit comments