Cross-Platform: Spike für Betrieb unter PowerShell 7 auf macOS/Linux
Windows-Verhalten bleibt identisch (Pfade/Temp verifiziert). Portable Anpassungen: - Get-AppDataDir/Test-IsWindows (Models.ps1): App-Daten unter macOS in ~/Library/Application Support, Linux in $XDG_CONFIG_HOME/~/.config; auf Windows unveraendert %APPDATA%. Settings- und Policy-Export-Pfad nutzen ihn. - ReportDir ueber [IO.Path]::GetTempPath() statt $env:TEMP (auf macOS/Linux leer). - Start.ps1: Browser plattformneutral oeffnen (open/xdg-open/Start-Process); WMI-Stale-Instanz-Erkennung nur noch auf Windows. - Datei-/Ordner-Dialog: macOS-nativer osascript-Chooser statt System.Windows.Forms; auf nicht unterstuetzten Plattformen klare Fehlermeldung. Auth (Device-Code-Flow) und HttpListener sind bereits plattformneutral. Test auf echtem macOS steht aus; Packaging (.app/.dmg) folgt separat. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -158,7 +158,8 @@ $script:Config = @{
|
||||
Scopes = @($script:Settings.connection.scopes)
|
||||
ScopesRo = @($script:Settings.connection.scopesRo)
|
||||
WebRoot = (Join-Path $root "www")
|
||||
ReportDir = (Join-Path $env:TEMP "IntuneAppManager-Reports")
|
||||
# Plattformneutrales Temp-Verzeichnis ($env:TEMP ist auf macOS/Linux leer).
|
||||
ReportDir = (Join-Path ([System.IO.Path]::GetTempPath()) "IntuneAppManager-Reports")
|
||||
}
|
||||
|
||||
if (-not (Test-Path $script:Config.ReportDir)) {
|
||||
@@ -206,7 +207,12 @@ Write-Host ""
|
||||
# das alte Fenster bedient weiter mit altem Code. Darum alle anderen Start.ps1-
|
||||
# Prozesse DIESES Pfads vorher beenden, damit ein Neustart wirklich neu laedt.
|
||||
# ============================================================
|
||||
try {
|
||||
# Nur auf Windows: die WMI-basierte Instanz-Erkennung (Win32_Process) gibt es
|
||||
# nur dort. Auf macOS/Linux uebernimmt das der Listener selbst (Port belegt ->
|
||||
# Fehler beim Start), ein manueller Neustart genuegt.
|
||||
$isWin = ($env:OS -eq 'Windows_NT') -or ($PSVersionTable.PSVersion.Major -lt 6) -or $IsWindows
|
||||
if ($isWin) {
|
||||
try {
|
||||
$thisScript = $PSCommandPath
|
||||
if ([string]::IsNullOrWhiteSpace($thisScript)) { $thisScript = Join-Path $PSScriptRoot 'Start.ps1' }
|
||||
# Nur echte Server-Instanzen treffen: per -File gestartet UND auf diesen
|
||||
@@ -220,8 +226,9 @@ try {
|
||||
catch { Write-Host " konnte PID $($p.ProcessId) nicht beenden: $($_.Exception.Message)" -ForegroundColor DarkYellow }
|
||||
}
|
||||
if ($stale.Count -gt 0) { Start-Sleep -Milliseconds 800 } # kurz warten bis der Port frei ist
|
||||
} catch {
|
||||
} catch {
|
||||
Write-Host " (Konnte alte Instanzen nicht pruefen: $($_.Exception.Message))" -ForegroundColor DarkGray
|
||||
}
|
||||
}
|
||||
|
||||
$url = "http://localhost:$Port/"
|
||||
@@ -232,7 +239,15 @@ Write-Host " Beenden: Ctrl+C" -ForegroundColor DarkGray
|
||||
Write-Host ""
|
||||
|
||||
if (-not $NoBrowser) {
|
||||
Start-Process $url
|
||||
# Browser plattformneutral oeffnen.
|
||||
try {
|
||||
if ($isWin) { Start-Process $url }
|
||||
elseif ($IsMacOS) { & /usr/bin/open $url }
|
||||
elseif ($IsLinux) { & xdg-open $url }
|
||||
else { Start-Process $url }
|
||||
} catch {
|
||||
Write-Host " (Browser konnte nicht automatisch geoeffnet werden - bitte $url manuell aufrufen.)" -ForegroundColor DarkGray
|
||||
}
|
||||
}
|
||||
|
||||
Start-WebServer -Port $Port
|
||||
|
||||
Reference in New Issue
Block a user