指定されたフィルターリストにIPアドレスを追加することにより、ドメインのipsecポリシーを変更するように設計されたPowerShellスクリプトがあります。問題はnetsh store location=domain domain=our.domain.com
、PowerShellスクリプトで実行すると、次のコマンドの保存場所が記憶されないことです。テキストファイルを作成して回避策を試しましたが、PowerShellから実行されますnetsh -f "path\to\textfile.txt"
が、機能しないようです。関連するスクリプトブロックを以下に示します。ドメインは、netshで直接実行すると機能するため、正しく設定されています。
$command = "ipsec static
set store location=domain domain=our.domain.com
add filter filterlist=$FILTERLIST
protocol=ANY srcaddr=$ip
srcmask=255.255.255.255
dstaddr=ME
description='IP address blocked'
mirrored=YES"
$($command.Trim()) | out-file $($DIR+"\netsh\temp.txt")
netsh -f $($DIR+"\netsh\temp.txt")
remove-item $($DIR+"\netsh\temp.txt")
まだ機能していませんが、これから実行するので、他に優れたソリューションがあるかどうかを知っておくと便利です。PowerShellv.1.0を実行しています