简体   繁体   English

使用 PowerShell 设置 IP 地址和域限制

[英]Setting IP address and domain restrictions using PowerShell

I am looking to automate deployment of a site.我正在寻找自动化站点的部署。

Within this site there are some folders that I wish to enable IP Address and Domain Restrictions on.在这个站点中有一些我希望启用 IP 地址和域限制的文件夹。 I have searched, however all the post that I can find show how to enable what I want to do, but using the IIS Manager GUI.我已经搜索过了,但是我能找到的所有帖子都显示了如何启用我想要做的事情,但是使用 IIS 管理器 GUI。 I am trying to determine how to do this using Powershell.我正在尝试确定如何使用 Powershell 执行此操作。

I have a site, www-a.contoso.com, and within this site I have a folder called secure.我有一个站点 www-a.contoso.com,在这个站点中我有一个名为 secure 的文件夹。

Within this secure folder, for the IP Address and Domain Restrictions I want to automate the following:在这个安全文件夹中,对于 IP 地址和域限制,我想自动执行以下操作:

  1. For Edit Feature Settings, set the access for Deny to an Deny Action Type of "Forbidden"对于编辑功能设置,将拒绝的访问权限设置为“禁止”的拒绝操作类型
  2. Add an allow entry for ip address 127.0.0.1为 ip 地址 127.0.0.1 添加允许条目

I only want to apply this to the secure folder and not the entire website.我只想将其应用于安全文件夹,而不是整个网站。

I am trying to do this on Windows 2012 R2, with IIS 8.5我正在尝试使用 IIS 8.5 在 Windows 2012 R2 上执行此操作

UPDATE更新

I have found that the following Powershell command will add in the allow ip address.我发现以下 Powershell 命令将添加允许 ip 地址。

add-webconfiguration -filter /system.webServer/security/ipSecurity -location "www-a.contoso.com/secure" -value @{ipAddress="127.0.0.1";allowed="true"} -PSPath "IIS:\"

and be specified at the secure folder only, while not affecting the rest of the site.并且仅在安全文件夹中指定,而不影响站点的其余部分。

However I still looking for Edit Feature Settings, set the access for Deny to an Deny Action Type of "Forbidden" for the secure folder但是我仍在寻找编辑功能设置,将拒绝的访问权限设置为安全文件夹的“禁止”操作类型

Many years later I imagine that you found the solution.许多年后,我想你找到了解决方案。 Anyway I post what I finally could make work fine:无论如何,我发布了我终于可以正常工作的内容:

Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -location "www-a.contoso.com/secure" -filter "system.webServer/security/ipSecurity" -name "allowUnlisted" -value "False" Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -location "www-a.contoso.com/secure" -filter "system.webServer/security/ipSecurity" -name "allowUnlisted" -value "False"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM