lara400
lara400

Reputation: 4736

Removing Element in ApplicationHost Config file

I am trying to remove centralBinaryLogFile element from the applicationHost config file:

I am using the below to remove this:

 Remove-WebConfigurationProperty -PSPath 'MACHINE/WEBROOT/APPHOST' -Filter 'system.applicationHost/log' -Name 'centralBinaryLogFile'

However, whenever it complains each time I try and remove it with the below:

**WARNING: Property centralBinaryLogFile is not found on  /system.applicationHost/log.**

I know it exists as if I run the below I get the element back fine:

Get-WebConfigurationProperty -PSPath 'MACHINE/WEBROOT/APPHOST' -Filter 'system.applicationHost/log' -Name 'centralBinaryLogFile'


enabled           : True
directory         : %SystemDrive%\inetpub\logs\LogFiles
period            : Daily
truncateSize      : 20971520
localTimeRollover : False
ItemXPath         : /system.applicationHost/log
Attributes        : {enabled, directory, period, truncateSize...}
ChildElements     : {}
ElementTagName    : centralBinaryLogFile
Methods           : 
Schema            : Microsoft.IIs.PowerShell.Framework.ConfigurationElementSchema

I also tried to use the below thinking a hash table might do the trick - but then it complains that Name is not a collection

Remove-WebconfigurationProperty -Filter "system.applicationHost/log" "Machine/WebRoot/AppHost" -Name centralBinaryLogFile -AtElement @{ElementTagName="centralBinaryLogFile"}

Any ideas how I remove this please?

Upvotes: 2

Views: 2503

Answers (2)

lara400
lara400

Reputation: 4736

In case someone else gets stuck and head is in a spin...do not use remove-webconfigurationproperty but CLEAR-WebConfiguration:

Clear-WebConfiguration -PSPath 'MACHINE/WEBROOT/APPHOST' -Filter 'system.applicationHost/log/centralBinaryLogFile' 

Upvotes: 7

dugas
dugas

Reputation: 12443

I attempted the same thing and got the same behavior. I know it's not removing it, but will disabling suffice?

Set-WebConfiguration -PSPath 'MACHINE/WEBROOT/APPHOST' -Filter 'system.applicationHost/log/centralBinaryLogFile' -value @{enabled=$false}

Upvotes: 2

Related Questions