1

我正在编写一个 Powershell 脚本来为使用 Powershell 的网站添加/删除/编辑 IP 限制。到目前为止,我能够添加限制,但想知道编辑现有 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 回答