iis 上通过 powershell 解除 Ip 和域限制

Remove Ip From Ip and domain restriction through powershell on iis

如何用powershell解除ip和域名限制?我尝试了很多参考解决方案,但我仍然无法解决它。请帮助我,

参考文献 1 Remove Ip From Ip and domain restriction through powershell 参考文献 2 https://www.titanwolf.org/Network/q/e32d7a33-0bf8-44c4-a162-dda21736d9d2/y

我想你可能需要检查现有的webconfig文件来确认修改的结果。 文件名:ApplicationHost.config 位置(IIS7或更高版本):%WinDir%\System32\Inetsrv\Config

对于下面的命令,我更改了您原来的位置,这不会有任何区别。

Set-WebConfigurationProperty /system.webserver/security/ipsecurity -Name allowUnlisted -Value "true" -Location "IIS:\Sites\default web site"

根据给定的图像,您在位置“system.webserver/security/ipsecurity”中将 属性 名称“allowUnlisted”的值设置为“true”,可以在那里找到。该部分将是

<system.webserver>
 <security>
  <ipSecurity allowUnlisted="true">
  </ipSecurity>
 </security>
</system.webserver>

然后,如果要更改上次的设置,只需将值修改为“false”即可。 命令:

Set-WebConfigurationProperty /system.webserver/security/ipsecurity -Name allowUnlisted -Value "false" -Location "IIS:\Sites\default web site"

结果将是:

<system.webserver>
     <security>
      <ipSecurity allowUnlisted="false">
      </ipSecurity>
     </security>
    </system.webserver>

关于命令的进一步用法,您可以阅读下面的示例。

命令:添加允许的ip

add-WebConfiguration /system.webserver/security/ipsecurity -Location "iis:\default web site" -Value @{ipaddress="192.168.1.1";allowed="true"} -PSPath IIS:\

结果:

   <system.webserver>
     <security>
      <ipSecurity allowUnlisted="false">
        <add ipAddress="192.168.1.1" allowed="true" />
      </ipSecurity>
     </security>
    </system.webserver>

命令:删除允许的 ip

Remove-WebConfigurationProperty /system.webServer/security/ipSecurity -location "iis:\default web site" -Name "." -AtElement @{ipAddress="192.168.1.1";allowed="true"}  -PSPath IIS:\

结果:

   <system.webserver>
     <security>
      <ipSecurity allowUnlisted="false">
      </ipSecurity>
     </security>
    </system.webserver>

另一种删除方法:将允许从“true”设置为“false” 命令:

Set-WebConfigurationProperty /system.webserver/security/ipsecurity -Name "." -AtElement @{ipAddress="192.168.1.1";allowed="true"} -Value @{ipAddress="192.168.1.1";allowed="false"} -Location "IIS:\Sites\default web site"

结果:

<system.webserver>
 <security>
  <ipSecurity allowUnlisted="false">
    <add ipAddress="192.168.1.1" allowed="false" />
  </ipSecurity>
 </security>
</system.webserver>

希望有所帮助。