我必须指定什么“名称”参数才能使用 Powershell 中的Remove-WebConfigurationProperty 删除 IIS 自定义错误?

Dyl*_*tie 1 iis powershell

尝试使用 Powershell 编写脚本从 IIS 网站删除特定的自定义错误。

我已经做到了这一点:

Remove-WebConfigurationProperty -Filter "/system.webServer/httpErrors/error[@statusCode='403' and @subStatusCode='4']" -Location IIS:\Sites\www.mysite.com
Run Code Online (Sandbox Code Playgroud)

但运行失败并出现警告:

Remove-WebConfigurationProperty : Cannot bind argument to parameter 'Name' because it is an empty string.
Run Code Online (Sandbox Code Playgroud)

我不知道Name在这里为参数指定什么 - 并且Remove-WebConfigurationProperty 的记录严重不足......有什么想法吗?

Dyl*_*tie 5

啊……破解了。它不是Remove-WebConfigurationProperty,而是在此上下文中使用的Clear-WebConfiguration:

Clear-WebConfiguration -Filter "/system.webServer/httpErrors/error[@statusCode='403' and @subStatusCode='4']" -Location IIS:\Sites\www.mysite.com
Run Code Online (Sandbox Code Playgroud)