# Shared helpers for USMT-Server.ps1, USMT-Worker.ps1 and Get-Software.ps1. # Dot-source this file; it must stay compatible with Windows PowerShell 5.1 and PowerShell 7. function Import-DashConfig { param([string]$Path, [switch]$Demo) if (-not $Path) { $Path = Join-Path (Split-Path $PSScriptRoot -Parent) "Config\usmt-dash.psd1" } $Path = $Path -replace '[\\/]', [System.IO.Path]::DirectorySeparatorChar if (-not (Test-Path $Path)) { throw "Config file not found: $Path" } $cfg = Import-PowerShellDataFile -Path $Path if ($Demo -or $env:USMT_MODE -eq 'Demo') { $cfg.Mode = 'Demo' } $cfg.IsDemo = ($cfg.Mode -eq 'Demo') return $cfg } function Join-DashPath { # Join-Path that tolerates the backslash-separated relative paths used in config on Linux param([string]$Base, [string]$Child) return Join-Path $Base ($Child -replace '[\\/]', [System.IO.Path]::DirectorySeparatorChar) } # ----------------------------------------------------------------------------------------- # Console log mirror # # Write-Host is proxied so every line printed to the console is also appended to a JSON # lines file: {"i":,"t":"