refactor(windows scripts): remove BOM and improve UTF-8 handling
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<#
|
||||
<#
|
||||
LXS - System Infos (Windows)
|
||||
Description: Essential system monitoring and diagnostic views.
|
||||
Read-only: nothing here changes the machine.
|
||||
@@ -20,7 +20,10 @@ if ($LxsLibPath -and (Test-Path $LxsLibPath)) {
|
||||
Write-Error 'Failed to fetch lib/common.ps1'
|
||||
exit 1
|
||||
}
|
||||
. ([scriptblock]::Create($LxsLibSource))
|
||||
# The library ships with a UTF-8 BOM (Windows PowerShell 5.1 needs it to
|
||||
# read the file as UTF-8); over HTTP that BOM arrives as a leading U+FEFF
|
||||
# character, which the parser will not accept.
|
||||
. ([scriptblock]::Create(($LxsLibSource -replace '^\uFEFF', '')))
|
||||
}
|
||||
|
||||
$env:LXS_LOG_FILE = Join-Path (Get-LxsTempDir) 'lxs_system_infos.log'
|
||||
@@ -63,7 +66,7 @@ function Show-LxsSystemInformation {
|
||||
ForEach-Object { "$($_.Name) (driver $($_.DriverVersion))" })
|
||||
if ($gpu.Count -gt 0) { Write-LxsField 'GPU' $gpu }
|
||||
} catch {
|
||||
# Headless or restricted WMI — not worth failing the whole view.
|
||||
# Headless or restricted WMI - not worth failing the whole view.
|
||||
}
|
||||
|
||||
# Activation status. LicenseStatus 1 = licensed.
|
||||
@@ -81,7 +84,7 @@ function Show-LxsSystemInformation {
|
||||
6 { 'Extended grace' }
|
||||
default { 'Unknown' }
|
||||
}
|
||||
Write-LxsField 'Activation' "$state — $($lic[0].Name)"
|
||||
Write-LxsField 'Activation' "$state - $($lic[0].Name)"
|
||||
}
|
||||
} catch {
|
||||
# SoftwareLicensingProduct is unavailable on some SKUs.
|
||||
@@ -172,7 +175,7 @@ function Show-LxsEventLogs {
|
||||
Show-LxsBoxTop -Title 'SYSTEM LOGS' -Right 'LAST 50'
|
||||
Write-Host ''
|
||||
foreach ($logName in @('System', 'Application')) {
|
||||
Write-Host "$($script:Cyan)$($script:Bold)$logName — errors and warnings$($script:NC)"
|
||||
Write-Host "$($script:Cyan)$($script:Bold)$logName - errors and warnings$($script:NC)"
|
||||
try {
|
||||
$events = Get-WinEvent -FilterHashtable @{ LogName = $logName; Level = 1, 2, 3 } -MaxEvents 25 -ErrorAction Stop
|
||||
$events | Format-Table -AutoSize -Wrap `
|
||||
|
||||
Reference in New Issue
Block a user