I'm trying to delete a custom log field on IIS using PowerShell. 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:
$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 -pspath 'MACHINE/WEBROOT/APPHOST' -filter "system.applicationHost/sites/siteDefaults/logFile/customFields" -name "." -AtElement @{logFieldName='TE'};
Just tested and it works
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.