qshinoの日記

Powershell関係と徒然なこと

Firewall 再び

Powershell でファイアーウォール設定

取得

TBD

設定

FTP port 21 設定。 - Data portの許可に関しては別途。

if (-not(Get-NetFirewallRule | where Name -match "ftp"))
{
    New-NetFirewallRule `
      -Name "FTP-test" `
        -DisplayName "FTP-test" `
      -Description "FTP-test" `
        -Group "FTP-test" `
      -Enabled True `
        -Profile Any `
      -Direction Inbound `
        -Action Allow `
      -EdgeTraversalPolicy Block `
        -LooseSourceMapping $False `
      -LocalOnlyMapping $False `
        -OverrideBlockRules $False `
      -Program Any `
        -LocalAddress Any `
      -RemoteAddress Any `
        -Protocol TCP `
      -LocalPort 21 `
        -RemotePort Any `
      -LocalUser Any `
        -RemoteUser Any 
}
else
{
        Write-Output "check ftp item"
        Get-NetFirewallPortFilter -Protocol TCP | where Localport -eq 21
}

参考

取得

https://guitarrapc.wordpress.com/wp-admin/post.php?post=2902&action=edit

設定

http://tech.guitarrapc.com/entry/2013/07/08/210724