Policies: ADMX-Import überspringt Einstellung sauber bei Presentation-Mismatch

Bei ingesteten ADMX mit abweichender Ziel-Version ließ sich eine Presentation
teils nicht zuordnen; bisher wurde die Einstellung dennoch (unvollständig)
gepostet -> 400 BadRequest. Jetzt wird die ganze Einstellung mit klarer Meldung
übersprungen, statt einen kaputten Body zu senden.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-09-23 12:37:55 +02:00
co-authored by Claude Opus 4.8
parent 300c72eb4f
commit c1751bec4d
+10 -2
View File
@@ -586,14 +586,18 @@ function Import-GraphAdministrativeTemplate {
try { $tgtPres = @(Get-GraphPaged -Uri "$defRoot/$defId/presentations" -AsRawJson) } catch { $tgtPres = @() } try { $tgtPres = @(Get-GraphPaged -Uri "$defRoot/$defId/presentations" -AsRawJson) } catch { $tgtPres = @() }
} }
$presVals = @() $presVals = @()
$typeCounter = @{} $typeCounter = @{}
$presFailed = $false
foreach ($pv in @(Get-PolicyProp $dv 'presentationValues')) { foreach ($pv in @(Get-PolicyProp $dv 'presentationValues')) {
if (-not $pv) { continue } if (-not $pv) { continue }
$pres = Get-PolicyProp $pv 'presentation' $pres = Get-PolicyProp $pv 'presentation'
if ($ingested) { if ($ingested) {
$presId = Resolve-TargetPresentationId -TargetPres $tgtPres -SrcPresentation $pres -Counter $typeCounter $presId = Resolve-TargetPresentationId -TargetPres $tgtPres -SrcPresentation $pres -Counter $typeCounter
if (-not $presId) { $errors += "${defName}: Presentation im Ziel nicht zuordenbar - Wert uebersprungen"; continue } # Presentation nicht zuordenbar (andere ADMX-Version im Ziel): die GANZE
# Einstellung ueberspringen, statt mit unvollstaendigem Body ein 400 zu
# provozieren.
if (-not $presId) { $presFailed = $true; break }
} else { } else {
$presId = [string](Get-PolicyProp $pres 'id') $presId = [string](Get-PolicyProp $pres 'id')
} }
@@ -608,6 +612,10 @@ function Import-GraphAdministrativeTemplate {
} }
$presVals += $entry $presVals += $entry
} }
if ($presFailed) {
$errors += "${defName}: Eingabefelder passen nicht zur Ziel-ADMX (andere Version?) - uebersprungen"
continue
}
$body = [ordered]@{ $body = [ordered]@{
enabled = [bool](Get-PolicyProp $dv 'enabled') enabled = [bool](Get-PolicyProp $dv 'enabled')