From 7b83a19db0989ae4677c798869941238e677a82e Mon Sep 17 00:00:00 2001 From: PTah Date: Wed, 3 Jun 2026 10:14:17 +1000 Subject: [PATCH] fix: InstallTasks fails when settings WinRM lines lack dollar sign (2.0.9-SAC) Defer login_monitor.settings.ps1 dot-source until after -InstallTasks so broken WinRM assignments cannot abort task registration. Deploy repairs settings lines missing $ before variable names. Co-authored-by: Cursor --- Deploy-LoginMonitor.ps1 | 36 ++++++++++++++++++++++++++++++++++++ Login_Monitor.ps1 | 26 +++++++++++++++++++++----- version.txt | 2 +- 3 files changed, 58 insertions(+), 6 deletions(-) diff --git a/Deploy-LoginMonitor.ps1 b/Deploy-LoginMonitor.ps1 index 2840abb..a33c727 100644 --- a/Deploy-LoginMonitor.ps1 +++ b/Deploy-LoginMonitor.ps1 @@ -500,6 +500,41 @@ function Test-RdpMonitorSettingsNeedsWinRmInboundBlock { return $false } +function Repair-RdpMonitorSettingsWinRmLinesIfInvalid { + param([string]$LocalSettings) + if (-not (Test-Path -LiteralPath $LocalSettings)) { return $false } + + $c = Get-RdpMonitorSettingsRaw -Path $LocalSettings + if ([string]::IsNullOrWhiteSpace($c)) { return $false } + + $winRmNames = @( + 'EnableWinRmInboundMonitoring', + 'WinRmLogName', + 'WinRmInboundShellEventIds', + 'WinRmCorrelateSecurity4624', + 'WinRm4624CorrelationWindowSeconds', + 'WinRmIgnoreLocalSource', + 'WinRmIgnoreMachineAccounts' + ) + $newContent = $c + $fixed = $false + foreach ($name in $winRmNames) { + $escaped = [regex]::Escape($name) + $pattern = "(?m)^(\s*)(?