用于在 IIS 高级日志记录的日志定义中启用日志记录字段的 Powershell 命令
Powershell command to enable logging fields in the log definition of IIS Advanced logging
我正在寻找一个 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 : Unexpected token Input:
get-config("MACHINE/WEBROOT/APPHOST")/system.webServer/advancedLogging/Server/log
Definitions/[@baseFileName='%COMPUTERNAME%-Server']/Fields Position:
93 Length: 1 Fragment: [ At D:\AdvanceLogging.ps1:10 char:1
+ Set-WebConfigurationProperty -Filter "system.webServer/advancedLoggin ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Set-WebConfigurationProperty], Argumen tException
+ FullyQualifiedErrorId : System.ArgumentException,Microsoft.IIs.PowerShell.Provide
r.SetConfigurationPropertyCommand
我不知道上面的命令是否正确,有人可以帮忙吗?
如果您想在服务器节点中添加该过滤器,请尝试此操作。
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'}
我正在寻找一个 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 : Unexpected token Input: get-config("MACHINE/WEBROOT/APPHOST")/system.webServer/advancedLogging/Server/log Definitions/[@baseFileName='%COMPUTERNAME%-Server']/Fields Position: 93 Length: 1 Fragment: [ At D:\AdvanceLogging.ps1:10 char:1 + Set-WebConfigurationProperty -Filter "system.webServer/advancedLoggin ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Set-WebConfigurationProperty], Argumen tException + FullyQualifiedErrorId : System.ArgumentException,Microsoft.IIs.PowerShell.Provide
r.SetConfigurationPropertyCommand
我不知道上面的命令是否正确,有人可以帮忙吗?
如果您想在服务器节点中添加该过滤器,请尝试此操作。
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'}