[英]Remove IIS custom log field with PowerShell
我正在嘗試使用 PowerShell 刪除 IIS 上的自定義日志字段。 我正在使用
Remove-WebConfigurationProperty -PSPath "MACHINE/WEBROOT/APPHOST" -Filter "system.applicationHost/sites/siteDefaults/logFile/customFields/add[logFieldName='TE']" -Name "." -AtIndex 0
但我收到以下消息:
WARNING: Target configuration object 'system.applicationHost/sites/siteDefaults/logFile/customFields/add[logFieldName=TE] is not found at path 'MACHINE/WEBROOT/APPHOST'.
如何刪除自定義字段?
我不確定您的方法是否有效,但是您可以通過以下方式輕松刪除自定義日志字段:
在 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
供將來參考:要運行的正確Remove-WebConfigurationProperty
cmdlet 是:
Remove-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -filter "system.applicationHost/sites/siteDefaults/logFile/customFields" -name "." -AtElement @{logFieldName='TE'};
剛剛測試,它的工作原理
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.