Geräte: Suche bezieht Modell/Hersteller mit ein
Client-Filter (Gruppen-Modus): Haystack um Manufacturer/Model erweitert. Server-Suche (alle Geräte): zusätzliche abgesicherte contains(model/manufacturer)- Teilabfrage, gemerged mit Name-/Serial-Treffern; bricht nicht, wenn das DeviceFE-Backend contains nicht unterstützt. Suchfeld-Platzhalter ergänzt. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
d19bf99e63
commit
15441eab35
3 files changed
+19
-3
No files matched your search
+17
-1
@@ -1889,6 +1889,7 @@ function Search-DevicesEndpoint {
|
||||
# Seriennummer wird separat per exaktem Filter gesucht und mit Name-Ergebnissen zusammengefuehrt.
|
||||
$nameItems = @()
|
||||
$snItems = @()
|
||||
$modelItems = @()
|
||||
|
||||
if ($q -and $q.Length -ge 2) {
|
||||
$osComp = @()
|
||||
@@ -1925,6 +1926,21 @@ function Search-DevicesEndpoint {
|
||||
$snResp = Invoke-MgGraphRequestRetry -Uri $snUri -Method GET
|
||||
$snItems = @($snResp.value)
|
||||
} catch { $snItems = @() }
|
||||
|
||||
# Modell / Hersteller: Teilstring-Suche (contains). Nicht jedes DeviceFE-Backend
|
||||
# unterstuetzt das -> abgesichert; bei Ablehnung bleibt die Modell-Suche einfach leer.
|
||||
$mdlFilters = @("(contains(model,'$q') or contains(manufacturer,'$q'))")
|
||||
if ($os) { $mdlFilters += "operatingSystem eq '$os'" }
|
||||
if ($compliance) { $mdlFilters += "complianceState eq '$compliance'" }
|
||||
$mdlFilter = '$filter=' + [uri]::EscapeDataString(($mdlFilters -join ' and ')) + '&'
|
||||
$mdlUri = "https://graph.microsoft.com/beta/deviceManagement/managedDevices?${mdlFilter}`$select=$select&`$top=$top"
|
||||
try {
|
||||
$mdlResp = Invoke-MgGraphRequestRetry -Uri $mdlUri -Method GET
|
||||
$modelItems = @($mdlResp.value)
|
||||
} catch {
|
||||
Write-Host " [DEVICES] Modell-/Hersteller-Suche (contains) nicht unterstuetzt -> uebersprungen" -ForegroundColor DarkYellow
|
||||
$modelItems = @()
|
||||
}
|
||||
} else {
|
||||
$filters = @()
|
||||
if ($os) { $filters += "operatingSystem eq '$os'" }
|
||||
@@ -1939,7 +1955,7 @@ function Search-DevicesEndpoint {
|
||||
|
||||
# Zusammenfuehren, Duplikate entfernen
|
||||
$seen = @{}
|
||||
$all = @($nameItems) + @($snItems)
|
||||
$all = @($nameItems) + @($snItems) + @($modelItems)
|
||||
$items = @()
|
||||
foreach ($d in $all) {
|
||||
if (-not $d.id -or $seen[$d.id]) { continue }
|
||||
|
||||
+1
-1
@@ -5846,7 +5846,7 @@ function devPassesFilters(d, q, os, cmp) {
|
||||
if (os && !(d.OS || '').toLowerCase().includes(os.toLowerCase())) return false;
|
||||
if (cmp && (d.ComplianceState || '') !== cmp) return false;
|
||||
if (q) {
|
||||
const hay = `${d.DeviceName || ''} ${d.UserDisplayName || ''} ${d.UserPrincipalName || ''} ${d.SerialNumber || ''}`.toLowerCase();
|
||||
const hay = `${d.DeviceName || ''} ${d.UserDisplayName || ''} ${d.UserPrincipalName || ''} ${d.SerialNumber || ''} ${d.Manufacturer || ''} ${d.Model || ''}`.toLowerCase();
|
||||
if (!hay.includes(q)) return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
+1
-1
@@ -484,7 +484,7 @@
|
||||
<div style="display:flex;align-items:center;gap:8px;padding:10px 16px;border-bottom:1px solid var(--hairline-soft);flex-shrink:0;">
|
||||
<div style="position:relative;display:flex;align-items:center;flex:1;min-width:0;">
|
||||
<svg style="position:absolute;left:10px;color:var(--muted);pointer-events:none;" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="11" cy="11" r="7"/><path d="M21 21l-4.3-4.3"/></svg>
|
||||
<input type="search" id="devSearch" style="width:100%;box-sizing:border-box;padding:0 12px 0 34px;height:34px;background:var(--canvas);border:1px solid var(--hairline);border-radius:6px;color:var(--ink);font-size:13px;font-family:inherit;" placeholder="Gerätename, Benutzer, Seriennummer…" autocomplete="off">
|
||||
<input type="search" id="devSearch" style="width:100%;box-sizing:border-box;padding:0 12px 0 34px;height:34px;background:var(--canvas);border:1px solid var(--hairline);border-radius:6px;color:var(--ink);font-size:13px;font-family:inherit;" placeholder="Gerätename, Benutzer, Seriennummer, Modell…" autocomplete="off">
|
||||
</div>
|
||||
<span id="devCount" class="count-badge">0</span>
|
||||
<select id="devOsFilter" style="height:34px;padding:0 8px;border:1px solid var(--hairline);border-radius:6px;background:var(--canvas);color:var(--ink);font-size:12.5px;cursor:pointer;">
|
||||
|
||||
Reference in new issue
Block a user