4

带有 IIS 8.5 的 Windows Server 2012 R2 允许使用增强日志记录的自定义日志字段

http://www.iis.net/learn/get-started/whats-new-in-iis-85/enhanced-logging-for-iis85

我想用 Powershell 添加字段

以下作品:

Set-ItemProperty IIS:\Sites\siteName -name logfile.customFields.collection -value
 @{logFieldName='foo';sourceType='RequestHeader';sourceName='c-ip'}

但我无法向 logfile.customFields.collection 添加第二个条目它请求 -Force 并覆盖现有条目

我通过 GUI 添加了 2 来说明问题

Get-ItemProperty IIS:\Sites\siteName -name logfile.customFields.collection

logFieldName   : foo
sourceName     : c-ip
sourceType     : RequestHeader
Attributes     : {logFieldName, sourceName, sourceType}
ChildElements  : {}
ElementTagName : add
Methods        :
Schema         : Microsoft.IIs.PowerShell.Framework.ConfigurationElementSchema

logFieldName   : foo2
sourceName     : c-servername
sourceType     : RequestHeader
Attributes     : {logFieldName, sourceName, sourceType}
ChildElements  : {}
ElementTagName : add
Methods        :
Schema         : Microsoft.IIs.PowerShell.Framework.ConfigurationElementSchema

logFieldName、sourceName 和 sourceType 是同名的 NoteProperty 成员

如何在 Powershell 中执行此操作?

4

1 回答 1

5

IIS 论坛上的一位用户回答了

   New-ItemProperty IIS:\Sites\siteName -name logfile.customFields.collection -value
         @{logFieldName='foo';sourceType='RequestHeader';sourceName='c-ip'}

   New-ItemProperty IIS:\Sites\siteName -name logfile.customFields.collection -value
         @{logFieldName='foo2';sourceType='RequestHeader';sourceName='c-ip'}

我确认这确实有效

于 2013-11-26T17:04:42.493 回答