【问题标题】:Powershell command to enable logging fields in the log definition of IIS Advanced logging用于在 IIS 高级日志记录的日志定义中启用日志记录字段的 Powershell 命令
【发布时间】:2020-04-08 13:33:59
【问题描述】:

我正在寻找一个 powershell 脚本来启用 IIS 高级日志记录中的一个日志记录定义中的字段。

请看下面的截图。

我尝试了以下命令。

Set-WebConfigurationProperty -Filter "system.webServer/advancedLogging/Server/logDefinitions/[@baseFileName='%COMPUTERNAME%-Server']/selectedFields" -PSPath machine/webroot/apphost -Name VIP_Name -value "True"

我收到以下错误

Set-WebConfigurationProperty:意外的令牌输入: 获取配置(“机器/WEBROOT/APPHOST”)/system.webServer/advancedLogging/Server/log 定义/[@baseFileName='%COMPUTERNAME%-Server']/字段位置: 93 长度:1 片段:[ 在 D:\AdvanceLogging.ps1:10 字符:1 + Set-WebConfigurationProperty -Filter "system.webServer/advancedLoggin ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Set-WebConfigurationProperty],参数 tException + FullyQualifiedErrorId : System.ArgumentException,Microsoft.IIs.PowerShell.Provide
r.SetConfigurationPropertyCommand

我不知道上面的命令是否正确,有人可以帮忙吗?

【问题讨论】:

标签: powershell iis advanced-custom-fields iis-advanced-logging


【解决方案1】:

如果您想在服务器节点中添加该过滤器,请试试这个。

Add-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST'  -filter "system.webServer/advancedLogging/server/logDefinitions/logDefinition[@baseFileName='%COMPUTERNAME%-Server']/selectedFields" -name "." -value @{id='VIP_Name';logHeaderName='VIP_Name'}

如果您想在站点级别设置过滤器,请使用此命令。

Add-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -location 'Default Web Site' -filter "system.webServer/advancedLogging/server/logDefinitions/logDefinition[@baseFileName='%COMPUTERNAME%-Server']/selectedFields" -name "." -value @{id='VIP_Name';logHeaderName='VIP_Name'}

【讨论】:

    猜你喜欢
    • 2012-06-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-05
    • 1970-01-01
    • 1970-01-01
    • 2016-08-01
    • 2013-06-16
    相关资源
    最近更新 更多