diff --git a/Login_Monitor.ps1 b/Login_Monitor.ps1 index 9fb5da8..5a9ec5d 100644 --- a/Login_Monitor.ps1 +++ b/Login_Monitor.ps1 @@ -365,6 +365,27 @@ function Enable-SecurityAudit { Write-Log "ВНИМАНИЕ: не удалось автоматически настроить аудит входа/выхода через auditpol. Скрипт продолжит работу, но часть событий может отсутствовать. Проверьте политику аудита вручную (локальная/доменная GPO)." } +function Test-RDSDeploymentPresent { + try { + if (Get-Command Get-WindowsFeature -ErrorAction SilentlyContinue) { + $rdsFeatures = @(Get-WindowsFeature -ErrorAction SilentlyContinue | Where-Object { + $_.Name -like 'RDS*' -and $_.InstallState -eq 'Installed' + }) + if ($rdsFeatures.Count -gt 0) { + return $true + } + } + } catch { } + + try { + if (Get-Service -Name 'UmRdpService' -ErrorAction SilentlyContinue) { + return $true + } + } catch { } + + return $false +} + function Send-Heartbeat { param([switch]$IsStartup = $false) @@ -374,6 +395,17 @@ function Send-Heartbeat { $message = "✅ Мониторинг логинов ЗАПУЩЕН`r`n" $message += "🖥️ Сервер: $env:COMPUTERNAME`r`n" $message += "🕐 Время запуска: $timestamp" + if (Test-RDSDeploymentPresent) { + $message += "`r`n🔐 RDS: обнаружена роль/компоненты Remote Desktop Services — в мониторинг входят также входы пользователей через RDS/RDP (события Security 4624/4625, типы входа по настройке скрипта)." + } + if ($EnableRDGatewayMonitoring) { + try { + $gwLog = Get-WinEvent -ListLog $RDGatewayLogName -ErrorAction SilentlyContinue + if ($gwLog) { + $message += "`r`n🌐 RD Gateway: журнал доступен — дополнительно фиксируются подключения через RD Gateway (302/303)." + } + } catch { } + } Send-TelegramMessage -Message $message | Out-Null Write-Log "Отправлено уведомление о запуске скрипта" } else { diff --git a/README.md b/README.md index ad150fb..7aa5b74 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,7 @@ powershell.exe -NoProfile -ExecutionPolicy Bypass -File "D:\Soft\Login_Monitor.p - `D:\Soft\Logs\watchdog.log` - Heartbeat: - `D:\Soft\Logs\last_heartbeat.txt` обновляется примерно раз в час (по `$HeartbeatInterval`). +- Telegram при старте: если обнаружена роль RDS (или типичный сервис RDS Session Host), в тексте явно указано, что мониторятся и входы через RDS/RDP; при доступном журнале RD Gateway — отдельная строка про события Gateway. ## 5) Автоматический перезапуск при падении