IIS高级日志记录 - 配置编辑器脚本

时间:2018-03-29 17:02:31

标签: powershell iis appcmd

我正在编写PowerShell脚本,以便对几台服务器上已经存在的高级日志记录进行一些修改。我遇到的主要问题是使用配置编辑器生成的以下命令:

.\appcmd.exe set config "wh01-02.testlab.com" -section:system.webServer/advancedLogging/server /+"logDefinitions.[baseFileName='Log404'].filter.condition.[operator='0'].[field='Status',operator='Equals',value='404']" /commit:apphost

当我运行此脚本时,出现以下错误:

ERROR ( message:Cannot find requested collection element. )

有点难过这个。想法有人吗?

1 个答案:

答案 0 :(得分:2)

好的,想通了。看起来我需要先创建'And'运算符,然后运行命令:

.\appcmd.exe set config "wh01-02.testlab.com" -section:system.webServer/advancedLogging/server /+"logDefinitions.[baseFileName='Log404'].filter.condition.[operator='And']" /commit:apphost
.\appcmd.exe set config "wh01-02.testlab.com" -section:system.webServer/advancedLogging/server /+"logDefinitions.[baseFileName='Log404'].filter.condition.[operator='And'].[field='Status',operator='Equals',value='404',caseSensitive='False',regularExpression='False']" /commit:apphost