File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -150,6 +150,7 @@ function New-CIPPCAPolicy {
150
150
$JSONObj.conditions.users .$groupType = @ (Replace- GroupNameWithId - groupNames $JSONObj.conditions.users .$groupType )
151
151
}
152
152
}
153
+
153
154
} catch {
154
155
$ErrorMessage = Get-CippException - Exception $_
155
156
Write-LogMessage - API ' Standards' - tenant $tenant - message " Failed to replace displayNames for conditional access rule $ ( $JSONObj.displayName ) . Error: $ ( $ErrorMessage.NormalizedError ) " - sev ' Error' - LogData $ErrorMessage
@@ -158,6 +159,27 @@ function New-CIPPCAPolicy {
158
159
}
159
160
}
160
161
$JsonObj.PSObject.Properties.Remove (' LocationInfo' )
162
+ foreach ($condition in $JSONObj.conditions.users.PSObject.Properties.Name ) {
163
+ $value = $JSONObj.conditions.users .$condition
164
+ if ($null -eq $value ) {
165
+ $JSONObj.conditions.users .$condition = @ ()
166
+ continue
167
+ }
168
+ if ($value -is [string ]) {
169
+ if ([string ]::IsNullOrWhiteSpace($value )) {
170
+ $JSONObj.conditions.users .$condition = @ ()
171
+ continue
172
+ }
173
+ }
174
+ if ($value -is [array ]) {
175
+ $nonWhitespaceItems = $value | Where-Object { -not [string ]::IsNullOrWhiteSpace($_ ) }
176
+ if ($nonWhitespaceItems.Count -eq 0 ) {
177
+ $JSONObj.conditions.users .$condition = @ ()
178
+ continue
179
+ }
180
+ }
181
+ }
182
+
161
183
$RawJSON = ConvertTo-Json - InputObject $JSONObj - Depth 10 - Compress
162
184
Write-Host $RawJSON
163
185
try {
You can’t perform that action at this time.
0 commit comments