powershell - 删除 ApplicationHost 配置文件中的元素

标签 powershell iis

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

我正在使用下面的方法来删除它:

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

但是,每当我尝试使用以下方法删除它时它都会提示:

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

我知道它存在,就好像我运行下面的命令一样,我可以很好地恢复元素:

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

我还尝试使用下面的方法,认为哈希表可以解决问题 - 但随后它提示 Name 不是一个集合

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

请问我如何删除它?

最佳答案

以防其他人被卡住并且头晕目眩……不要使用 remove-webconfigurationproperty,而是使用 CLEAR-WebConfiguration:

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

关于powershell - 删除 ApplicationHost 配置文件中的元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34600984/

相关文章:

c# - 如何让IIS识别OWIN启动类?

IIS sc-win32-状态码

angular - 如何在 Angular 项目的 webpack 中配置 gzip 压缩?

c# - 无法上传 Ppt 并在 IIS 服务器中读取

powershell - 如何在Powershell中处理大型CSV文件

html - 如何使用 Powershell Core 7 解析 HTML 表格?

powershell - 使用 PowerShell 命令 Start-Process 安装 msi 时,出现退出代码 1603 错误

iis - 如果 IIS 服务器未运行,则启动 IIS 服务器

powershell - CSV导入Powershell-AD

list - Powershell 列出串行端口 + 说明