Policies: ADMX-Presentation-Matching Hashtable-Bug behoben (PS7/Container)
Where-Object liefert bei einem Treffer ein Einzelobjekt. Ist das eine Hashtable (PS7 ConvertFrom-Json -AsHashtable, wie im Docker-Container), war $sameType[0] eine Schluessel-Suche nach Key 0 (=> $null) statt Array-Index -> Presentation wurde als "nicht zuordenbar" gewertet und die Einstellung uebersprungen. Unter Windows PowerShell 5.1 (PSCustomObjects) trat der Fehler nicht auf. Fix: Where-Object-Ergebnis vor dem Indexieren in @() zwingen. Verifiziert per Simulation gegen die realen Firefox-ADMX-Exportdaten (Default Search Engine, URL for Home page). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+8
-4
@@ -538,14 +538,18 @@ function Resolve-TargetPresentationId {
|
||||
} | Select-Object -First 1
|
||||
if ($m) { return [string](Get-PolicyProp $m 'id') }
|
||||
}
|
||||
# 2) i-te Ziel-Presentation gleichen Typs (in Reihenfolge)
|
||||
# 2) i-te Ziel-Presentation gleichen Typs (in Reihenfolge).
|
||||
# WICHTIG: Ergebnis in @() zwingen - bei EINEM Treffer liefert Where-Object ein
|
||||
# Einzelobjekt; ist das eine Hashtable (PS7 -AsHashtable), waere $x[0] eine
|
||||
# Schluessel-Suche nach Key 0 (=> $null) statt Array-Index -> Fehlmatch.
|
||||
$idx = 0; if ($Counter.ContainsKey($srcType)) { $idx = [int]$Counter[$srcType] }
|
||||
$sameType = @($TargetPres) | Where-Object { (& $norm (Get-PolicyProp $_ '@odata.type')) -eq $srcType }
|
||||
$sameType = @(@($TargetPres) | Where-Object { (& $norm (Get-PolicyProp $_ '@odata.type')) -eq $srcType })
|
||||
$Counter[$srcType] = $idx + 1
|
||||
if ($idx -lt @($sameType).Count) { return [string](Get-PolicyProp $sameType[$idx] 'id') }
|
||||
if ($idx -lt $sameType.Count) { return [string](Get-PolicyProp $sameType[$idx] 'id') }
|
||||
# 3) Letzter Fallback: hat die Ziel-Definition genau EINE Presentation, nimm sie
|
||||
# (deckt Ein-Feld-Settings wie Textboxen zuverlaessig ab).
|
||||
if (@($TargetPres).Count -eq 1) { return [string](Get-PolicyProp $TargetPres[0] 'id') }
|
||||
$allTgt = @($TargetPres)
|
||||
if ($allTgt.Count -eq 1) { return [string](Get-PolicyProp $allTgt[0] 'id') }
|
||||
return $null
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user