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:
marcoandClaude Opus 4.8 committed 2026-11-09 12:34:02 +01:00
1 parent d19bf99e63
commit 15441eab35
3 files changed
+21 -5

No files matched your search

+19 -3
View File
@@ -1887,8 +1887,9 @@ function Search-DevicesEndpoint {
# Ohne Suchbegriff: alle Geräte (erste Seite)
# Mit Suchbegriff: Graph unterstuetzt startswith nur auf deviceName/userDisplayName/userPrincipalName.
# Seriennummer wird separat per exaktem Filter gesucht und mit Name-Ergebnissen zusammengefuehrt.
$nameItems = @()
$snItems = @()
$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 }