[CmdletBinding()] param( [string]$Csv ) $ErrorActionPreference = 'Stop' $key = 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server' $props = Get-ItemProperty -LiteralPath $key -ErrorAction Stop $settings = [pscustomobject]@{ RDPEnabled = ($props.fDenyTSConnections -eq 0) DenyTSConnections = $props.fDenyTSConnections UserAuthentication = $props.UserAuthentication SecurityLayer = $props.SecurityLayer MinEncryptionLevel = $props.MinEncryptionLevel SingleSessionPerUser = $props.fSingleSessionPerUser } $listeners = @(Get-NetTCPConnection -LocalPort 3389 -State Listen -ErrorAction SilentlyContinue | Select-Object LocalAddress, LocalPort, OwningProcess) Write-Host 'Параметры RDP:' $settings | Format-List Write-Host 'Прослушивание порта 3389:' if ($listeners.Count -gt 0) { $listeners | Format-Table -AutoSize } else { Write-Host 'Порт 3389 не прослушивается.' } if ($Csv) { $parent = Split-Path -Parent $Csv if ($parent -and -not (Test-Path -LiteralPath $parent)) { New-Item -ItemType Directory -Path $parent | Out-Null } $settings | Export-Csv -LiteralPath $Csv -NoTypeInformation -Encoding UTF8 Write-Host "Отчёт сохранён: $Csv" } Write-Host 'Настройки RDP не изменялись.'