0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

WindowsサーバーのFirewall設定をCSVで出力する

Last updated at Posted at 2025-07-07

概要

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
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?