Powershell IIS条件Url重写匹配类型的Power shell脚本

Powershell IIS条件Url重写匹配类型的Power shell脚本,powershell,iis,Powershell,Iis,我一直致力于在IIS上编写powershell脚本,添加Url重写条件。下面是一个示例代码 Add-WebConfigurationProperty -pspath 'iis:\sites\Sample' -filter "system.webServer/rewrite/rules" -name "." -value @{name='Redirect www.google.com' ;patternSyntax='Regular Expressions' ;enabled='True' ;}

我一直致力于在IIS上编写powershell脚本,添加Url重写条件。下面是一个示例代码

Add-WebConfigurationProperty -pspath 'iis:\sites\Sample'  -filter "system.webServer/rewrite/rules" -name "." -value @{name='Redirect www.google.com' ;patternSyntax='Regular Expressions' ;enabled='True' ;}
Set-WebConfigurationProperty -pspath $site -filter "$filterRoot/match" -name "url" -value "(^test/(.*)|^test($|/$))*"

$list = @{
    pspath = 'MACHINE/WEBROOT/APPHOST/Sample'
    filter = "/system.webServer/rewrite/rules/rule[@name='Redirect www.google.com']/conditions"
    Value = @{
        input = '{REMOTE_ADDR}'
        matchType ='0'
        pattern ='192.100.100.01'
        ignoreCase ='True'
        negate ='True'
    },
    @{
        input = '{REMOTE_ADDR}'
        matchType ='IsFile'
        pattern ='192.100.100.01'
        ignoreCase ='True'
        negate ='True'
    }
   }
   Add-WebConfiguration @list

在$list中,我想将matchType设置为“matchesthepattern”。这是我想要的IIS中条件设置的相关匹配类型。设置此选项需要什么匹配类型?

matchType
是一个具有三个值的枚举:

IsDirectory = 2     
IsFile      = 1     
Pattern     = 0
“模式”是您想要的(您可以看到这实际上是默认的)。因此,您可以使用:

matchType = 'Pattern'

# or this should also work:
matchType = 0
()

要将其设置为“匹配模式”,请设置:


当我不提供匹配类型时,它会自动将类型设置为“不匹配模式”类型。matchType=“Pattern”时也会发生同样的情况。我想设置的是“匹配模式”类型。@IshanthaKamal我猜是“否定”选项,但我不确定,目前无法测试它。尝试将其设置为“False”,这是“否定”选项设置。非常感谢你。
negate = 'False'