2013-02-27 37 views
1

我正在编写一个Powershell脚本来为使用Powershell的网站添加/删除/编辑IP限制。到目前为止,我可以添加限制,但是想知道编辑现有IP限制的最佳方法。使用Powershell编辑现有IIS 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:\" 

基本上清除所有的最好方式,而每一次重建?

回答

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

此命令将文件夹中的所有页面项。 – 2016-06-09 14:40:13