1

Powershell を使用して Web サイトの IP 制限を追加/削除/編集する Powershell スクリプトを作成しています。これまでのところ、制限を追加することはできますが、既存の IP 制限を編集する最良の方法を知りたい.

追加

Add-WebConfiguration -Filter /system.webserver/security/ipsecurity -Value @{ipAddress=$ipAddress;subnetMask="255.255.255.255";allowed=$allowed} -Location $websiteName -PSPath "IIS:\"

編集

次のさまざまな組み合わせを試しました。

Set-WebConfiguration -Filter system.webServer/security/ipSecurity/add[@ipAddress='192.123.123.123'] -Name "ipAddress" -Value $ipAddress -Location $websiteName -PSPath "IIS:\"

Set-WebConfigurationProperty -Filter system.webServer/security/ipSecurity/add[@ipAddress='192.123.123.123'] -Value = @{ipAddress=$ipAddress;subnetMask="255.255.255.255";allowed=$allowed} -Location $websiteName -PSPath "IIS:\"

基本的にすべてをクリアし、毎回再作成するのが最善の方法ですか?

4

1 に答える 1

0

私は同じ問題を抱えていて、このように修正しました-

# Compose new entry    
$value = @{allowed="true";ipAddress="192.168.0.1"}

# Add new entry to restrictions
Add-WebConfigurationProperty  -Filter 'system.webServer/security/ipSecurity' -PSPath "IIS:\Sites\MySite\" -Location "MyService" -Name "." -Value $value -ErrorAction Stop
于 2014-12-19T14:59:01.977 に答える