[CmdletBinding()] param( [string]$Csv ) $ErrorActionPreference = 'Stop' if (-not (Get-Command Get-NetFirewallProfile -ErrorAction SilentlyContinue)) { throw 'Модуль NetSecurity недоступен. Нужна Windows 10 или 11.' } $profiles = @(Get-NetFirewallProfile -ErrorAction Stop | Select-Object Name, Enabled, DefaultInboundAction, DefaultOutboundAction, LogAllowed, LogBlocked, LogFileName) $rules = @(Get-NetFirewallRule -Enabled True -Direction Inbound -ErrorAction Stop | Select-Object DisplayName, DisplayGroup, Action, Profile, PolicyStoreSourceType | Sort-Object DisplayGroup, DisplayName) Write-Host 'Профили брандмауэра:' $profiles | Format-Table -AutoSize Write-Host ("Включённых входящих правил: {0}" -f $rules.Count) $rules | Select-Object -First 50 | Format-Table -AutoSize if ($Csv) { $parent = Split-Path -Parent $Csv if ($parent -and -not (Test-Path -LiteralPath $parent)) { New-Item -ItemType Directory -Path $parent | Out-Null } $rules | Export-Csv -LiteralPath $Csv -NoTypeInformation -Encoding UTF8 Write-Host "Полный список сохранён: $Csv" }