[英]Remove IIS custom log field with PowerShell
I'm trying to delete a custom log field on IIS using PowerShell.我正在尝试使用 PowerShell 删除 IIS 上的自定义日志字段。 I'm using
我正在使用
Remove-WebConfigurationProperty -PSPath "MACHINE/WEBROOT/APPHOST" -Filter "system.applicationHost/sites/siteDefaults/logFile/customFields/add[logFieldName='TE']" -Name "." -AtIndex 0
But I get the following message:但我收到以下消息:
WARNING: Target configuration object 'system.applicationHost/sites/siteDefaults/logFile/customFields/add[logFieldName=TE] is not found at path 'MACHINE/WEBROOT/APPHOST'.
How can I delete the custom field?如何删除自定义字段?
I'm not sure if your approach will work or not, however you can easily remove custom log fields by:我不确定您的方法是否有效,但是您可以通过以下方式轻松删除自定义日志字段:
In POSH:在 POSH 中:
$currentFields = Get-WebConfigurationProperty -Filter System.Applicationhost/Sites/SiteDefaults/logfile -Name LogExtFileFlags
$currentFields = $currentFields.Replace(",TE", "");
Set-WebConfigurationProperty -Filter System.Applicationhost/Sites/SiteDefaults/logfile -Name LogExtFileFlags -Value $currentFields
For future refences: The correct Remove-WebConfigurationProperty
cmdlet to run is:供将来参考:要运行的正确
Remove-WebConfigurationProperty
cmdlet 是:
Remove-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -filter "system.applicationHost/sites/siteDefaults/logFile/customFields" -name "." -AtElement @{logFieldName='TE'};
Just tested and it works刚刚测试,它的工作原理
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.