Skip to content

Commit d2aecb2

Browse files
minor update to fix grantControls
1 parent e228a4e commit d2aecb2

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

Modules/CIPPCore/Public/New-CIPPCAPolicy.ps1

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,11 @@ function New-CIPPCAPolicy {
9393
#Remove context as it does not belong in the payload.
9494
try {
9595
if ($JSONobj.grantControls) {
96-
$JSONobj.grantControls.PSObject.Properties.Remove('authenticationStrength@odata.context')
96+
try {
97+
$JSONobj.grantControls.PSObject.Properties.Remove('authenticationStrength@odata.context')
98+
} catch {
99+
#did not need to remove because didn't exist.
100+
}
97101
}
98102
$JSONobj.templateId ? $JSONobj.PSObject.Properties.Remove('templateId') : $null
99103
if ($JSONobj.conditions.users.excludeGuestsOrExternalUsers.externalTenants.Members) {
@@ -428,7 +432,7 @@ function New-CIPPCAPolicy {
428432
# Preserve any exclusion groups named "Vacation Exclusion - <PolicyDisplayName>" from existing policy
429433
try {
430434
$ExistingVacationGroup = New-GraphGETRequest -uri "https://graph.microsoft.com/beta/groups?`$filter=startsWith(displayName,'Vacation Exclusion')&`$select=id,displayName&`$top=999&`$count=true" -ComplexFilter -tenantid $TenantFilter -asApp $true |
431-
Where-Object { $CheckExisting.conditions.users.excludeGroups -contains $_.id }
435+
Where-Object { $CheckExisting.conditions.users.excludeGroups -contains $_.id }
432436
if ($ExistingVacationGroup) {
433437
if (-not ($JSONobj.conditions.users.PSObject.Properties.Name -contains 'excludeGroups')) {
434438
$JSONobj.conditions.users | Add-Member -NotePropertyName 'excludeGroups' -NotePropertyValue @() -Force

0 commit comments

Comments
 (0)