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*)(?