【问题标题】:Edit an existing IIS IP Restriction with Powershell使用 Powershell 编辑现有 IIS IP 限制
【发布时间】:2013-02-27 23:25:48
【问题描述】:

我正在编写一个 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:\"

基本上是清除所有并重新创建的最好方法吗?

【问题讨论】:

    标签: iis powershell iis-7


    【解决方案1】:

    我遇到了同样的问题并这样解决了 -

    # 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
    

    【讨论】:

      猜你喜欢
      • 2021-08-25
      • 2014-03-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-17
      • 1970-01-01
      • 1970-01-01
      • 2016-02-21
      相关资源
      最近更新 更多