diff --git a/src/PolicyIO.ps1 b/src/PolicyIO.ps1
index efa2746..d947b61 100644
--- a/src/PolicyIO.ps1
+++ b/src/PolicyIO.ps1
@@ -1121,9 +1121,42 @@ function Invoke-PolicyConsolidateEndpoint {
# ============================================================
# Zwei Settings-Catalog-Policies vergleichen (Diff nach settingDefinitionId)
# ============================================================
-# Body: { ids:[idA, idB] }. Liefert: nur in A / nur in B / gleich / unterschiedlich.
-# Nutzt dieselbe Extraktion wie die Konsolidierung (Get-SettingDefinitionId +
-# Get-SettingCanonicalJson -> kanonischer Wert-Vergleich).
+# Kompakter, lesbarer Wert einer settingInstance (fuer die Gegenueberstellung).
+# Best-effort: Choice -> letzte Wert-Komponente, Simple -> Wert, Collections -> Liste/Anzahl.
+# Das volle (kanonische) JSON bleibt separat erhalten.
+function Get-SettingDisplayValue {
+ param($SettingElement)
+ $si = Get-PolicyProp $SettingElement 'settingInstance'
+ if (-not $si) { $si = $SettingElement }
+
+ $cv = Get-PolicyProp $si 'choiceSettingValue'
+ if ($cv) {
+ $v = [string](Get-PolicyProp $cv 'value')
+ $tail = ($v -split '_')[-1]
+ $kids = @(Get-PolicyProp $cv 'children') | Where-Object { $_ }
+ if (@($kids).Count -gt 0) { return "$tail (+$(@($kids).Count) Unter)" }
+ return $tail
+ }
+ $sv = Get-PolicyProp $si 'simpleSettingValue'
+ if ($sv) { return [string](Get-PolicyProp $sv 'value') }
+ $scv = @(Get-PolicyProp $si 'simpleSettingCollectionValue') | Where-Object { $_ }
+ if (@($scv).Count -gt 0) {
+ $joined = (@($scv | ForEach-Object { [string](Get-PolicyProp $_ 'value') }) -join ', ')
+ if ($joined.Length -gt 140) { $joined = $joined.Substring(0, 137) + '...' }
+ return $joined
+ }
+ $ccv = @(Get-PolicyProp $si 'choiceSettingCollectionValue') | Where-Object { $_ }
+ if (@($ccv).Count -gt 0) {
+ return (@($ccv | ForEach-Object { ([string](Get-PolicyProp $_ 'value') -split '_')[-1] }) -join ', ')
+ }
+ $gcv = @(Get-PolicyProp $si 'groupSettingCollectionValue') | Where-Object { $_ }
+ if (@($gcv).Count -gt 0) { return "$(@($gcv).Count) Gruppe(n)" }
+ return ''
+}
+
+# Body: { ids:[idA, idB] }. Liefert A/B-Metadaten + vereinheitlichte Zeilen (Union
+# der settingDefinitionId), jede mit Status (same|different|onlyA|onlyB) sowie
+# Kurzwert und vollem (kanonischem) Wert je Seite - fuer die Gegenueberstellung.
function Invoke-PolicyCompareEndpoint {
param($Body)
try { Assert-GraphConnected } catch { return @{ __status = 401; error = 'Nicht mit Microsoft Graph verbunden' } }
@@ -1141,7 +1174,7 @@ function Invoke-PolicyCompareEndpoint {
if (-not $el) { continue }
$defId = Get-SettingDefinitionId $el
if (-not $defId) { continue }
- $map[$defId] = Get-SettingCanonicalJson $el
+ $map[$defId] = @{ canon = Get-SettingCanonicalJson $el; short = Get-SettingDisplayValue $el }
}
$pols += @{
id = [string]$id
@@ -1153,28 +1186,36 @@ function Invoke-PolicyCompareEndpoint {
}
$a = $pols[0]; $b = $pols[1]
- $onlyA = @(); $onlyB = @(); $same = @(); $different = @()
- foreach ($k in @($a.map.Keys)) {
- if ($b.map.Contains($k)) {
- if ($a.map[$k] -eq $b.map[$k]) { $same += @{ settingDefinitionId = $k; value = $a.map[$k] } }
- else { $different += @{ settingDefinitionId = $k; valueA = $a.map[$k]; valueB = $b.map[$k] } }
- } else {
- $onlyA += @{ settingDefinitionId = $k; value = $a.map[$k] }
- }
- }
- foreach ($k in @($b.map.Keys)) {
- if (-not $a.map.Contains($k)) { $onlyB += @{ settingDefinitionId = $k; value = $b.map[$k] } }
+ # Union der Keys: A-Reihenfolge, dann die nur in B vorhandenen anhaengen.
+ $keys = [System.Collections.Generic.List[string]]::new()
+ foreach ($k in @($a.map.Keys)) { [void]$keys.Add([string]$k) }
+ foreach ($k in @($b.map.Keys)) { if (-not $a.map.Contains($k)) { [void]$keys.Add([string]$k) } }
+
+ $rows = @()
+ $cDiff = 0; $cOnlyA = 0; $cOnlyB = 0; $cSame = 0
+ foreach ($k in $keys) {
+ $inA = $a.map.Contains($k); $inB = $b.map.Contains($k)
+ $ea = $null; $eb = $null
+ if ($inA) { $ea = $a.map[$k] }
+ if ($inB) { $eb = $b.map[$k] }
+
+ $status = ''
+ if ($inA -and $inB) {
+ if ($ea.canon -eq $eb.canon) { $status = 'same'; $cSame++ } else { $status = 'different'; $cDiff++ }
+ } elseif ($inA) { $status = 'onlyA'; $cOnlyA++ } else { $status = 'onlyB'; $cOnlyB++ }
+
+ $row = [ordered]@{ id = $k; status = $status }
+ if ($inA) { $row['shortA'] = $ea.short; $row['fullA'] = $ea.canon }
+ if ($inB) { $row['shortB'] = $eb.short; $row['fullB'] = $eb.canon }
+ $rows += $row
}
return @{
- ok = $true
- a = @{ id = $a.id; name = $a.name; platform = $a.platform; count = $a.count }
- b = @{ id = $b.id; name = $b.name; platform = $b.platform; count = $b.count }
- onlyA = @($onlyA)
- onlyB = @($onlyB)
- same = @($same)
- different = @($different)
- counts = @{ onlyA = @($onlyA).Count; onlyB = @($onlyB).Count; same = @($same).Count; different = @($different).Count }
+ ok = $true
+ a = @{ id = $a.id; name = $a.name; platform = $a.platform; count = $a.count }
+ b = @{ id = $b.id; name = $b.name; platform = $b.platform; count = $b.count }
+ rows = @($rows)
+ counts = @{ different = $cDiff; onlyA = $cOnlyA; onlyB = $cOnlyB; same = $cSame }
}
}
diff --git a/www/app.js b/www/app.js
index fc68c8b..cc5c80f 100644
--- a/www/app.js
+++ b/www/app.js
@@ -6619,6 +6619,7 @@ document.getElementById('polConsConfirm')?.addEventListener('click', polDoConsol
// Policies vergleichen (zwei Settings-Catalog-Policies -> Diff)
// =============================================================
let _polCmpResult = null;
+let _polCmpOnlyDiff = false;
async function openPolCompare() {
const keys = [...PolState.selected].filter(k => k.startsWith('settingscatalog::'));
@@ -6645,48 +6646,53 @@ function polCmpShortId(id) {
return `${escapeHtml(tail)} ${escapeHtml(s)}`;
}
-function polCmpVal(v) {
- return `${escapeHtml(String(v ?? ''))}`;
+// Eine Wert-Zelle (Kurzwert sichtbar, volles JSON als Tooltip). Leer = „—".
+function polCmpCell(short, full, extraCls) {
+ if (short == null && full == null) return '