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
$groupId=$matchedGroups.id# it's a display name, so we get the group ID
29
30
if ($groupId) {
31
+
if ($matchedGroups.Count-gt1) {
32
+
Write-Warning"Multiple groups found with display name '$_'. Using the first match: $($matchedGroups[0].id). IDs found: $($groupId-join', ')"
33
+
$null=Write-LogMessage-Headers $Headers-API $APIName-message "Multiple groups found with display name '$_'. Using first match: $($matchedGroups[0].id)"-Sev 'Warn'
34
+
$groupId=@($matchedGroups[0].id)
35
+
}
30
36
foreach ($gidin$groupId) {
31
37
Write-Warning"Replaced group name $_ with ID $gid"
32
38
$null=Write-LogMessage-Headers $Headers-API $APIName-message "Replaced group name $_ with ID $gid"-Sev 'Debug'
@@ -218,7 +224,12 @@ function New-CIPPCAPolicy {
218
224
if (!$location.displayName) { continue }
219
225
# Use cached named locations instead of fetching each time
220
226
if ($Location.displayName-in$AllNamedLocations.displayName) {
Write-Warning"Multiple named locations found with display name '$($Location.displayName)'. Using the first match: $($ExistingLocation[0].id). IDs found: $($ExistingLocation.id-join', ')"
230
+
Write-LogMessage-Tenant $TenantFilter-Headers $Headers-API $APIName-message "Multiple named locations found with display name '$($Location.displayName)'. Using first match: $($ExistingLocation[0].id)"-Sev 'Warn'
231
+
}
232
+
$ExistingLocation=$ExistingLocation[0]
222
233
if ($Overwrite) {
223
234
$LocationUpdate=$location|Select-Object*-ExcludeProperty id
224
235
Remove-ODataProperties-Object $LocationUpdate
@@ -275,8 +286,9 @@ function New-CIPPCAPolicy {
275
286
throw"Failed to create named location $($location.displayName): $($ErrorMessage.NormalizedError)"
276
287
}
277
288
[pscustomobject]@{
278
-
id=$GraphRequest.id
279
-
name=$GraphRequest.displayName
289
+
id=$GraphRequest.id
290
+
name=$GraphRequest.displayName
291
+
templateId=$location.id
280
292
}
281
293
}
282
294
}
@@ -287,7 +299,7 @@ function New-CIPPCAPolicy {
287
299
if ($LocationLookupTable-and$JSONobj.conditions.locations) {
0 commit comments