概要
WindowsサーバーのFirewall設定をCSVで出力するPowerShellコマンド。
以下の情報を出力可能。
・Name
⇒ルールの内部名(システムが使う識別名)
・DisplayName
⇒ルールの表示名(GUIや一覧に表示される日本語名)
・Group
⇒グループ(空欄だとカスタムでそうでないものは既定だと判別可能)
・Profile
⇒適用されるプロファイル
Domain/Private/Public/Anyのいずれか
・Direction
⇒通信方向
Inbound(受信)/Outbound(送信)
・Action
⇒アクション
Allow(許可)/Block(ブロック)
・Enabled
⇒ルールが有効かどうか
True(有効)/False(無効)
<コマンド>
Get-NetFirewallRule |
Select-Object Name, DisplayName, Group, Profile, Direction, Action, Enabled |
Export-Csv -Path "C:\temp\firewall_rules_simple.csv" -NoTypeInformation -Encoding Default
<おまけ:FW設定を追加するコマンド>
# HTTP許可(ポート80)
New-NetFirewallRule -Name "Allow_HTTP" -DisplayName "Allow HTTP" -Direction Inbound -Action Allow -Protocol TCP -LocalPort 80 -Profile Domain