删除 ApplicationHost 配置文件中的元素

lar*_*400 1 iis powershell

我正在尝试centralBinaryLogFile从 applicationHost 配置文件中删除元素:

我正在使用以下内容来删除它:

 Remove-WebConfigurationProperty -PSPath 'MACHINE/WEBROOT/APPHOST' -Filter 'system.applicationHost/log' -Name 'centralBinaryLogFile'
Run Code Online (Sandbox Code Playgroud)

但是,每当我尝试使用以下命令将其删除时它都会抱怨:

**WARNING: Property centralBinaryLogFile is not found on  /system.applicationHost/log.**
Run Code Online (Sandbox Code Playgroud)

我知道它存在,就好像我运行下面我得到的元素很好:

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
Run Code Online (Sandbox Code Playgroud)

我还尝试使用下面的想法,认为哈希表可能会奏效 - 但随后它抱怨 Name 不是一个集合

Remove-WebconfigurationProperty -Filter "system.applicationHost/log" "Machine/WebRoot/AppHost" -Name centralBinaryLogFile -AtElement @{ElementTagName="centralBinaryLogFile"}
Run Code Online (Sandbox Code Playgroud)

任何想法我如何删除它?

lar*_*400 6

万一其他人被卡住并且头脑混乱……不要使用remove-webconfigurationproperty,而是使用CLEAR-WebConfiguration:

Clear-WebConfiguration -PSPath 'MACHINE/WEBROOT/APPHOST' -Filter 'system.applicationHost/log/centralBinaryLogFile' 
Run Code Online (Sandbox Code Playgroud)