2012-06-19 12 views
0

嘗試使用Powershell腳本從IIS網站中刪除特定的自定義錯誤。必須使用Powershell中的Remove-WebConfigurationProperty指定什麼「名稱」參數來刪除IIS自定義錯誤?

我有這麼遠:

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

但運行失敗,並警告:

Remove-WebConfigurationProperty : Cannot bind argument to parameter 'Name' because it is an empty string. 

我不知道到指定這裏Name參數 - 和Remove-WebConfigurationProperty是可悲的沒有記錄...任何想法?

回答

3

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

Clear-WebConfiguration -Filter "/system.webServer/httpErrors/error[@statusCode='403' and @subStatusCode='4']" -Location IIS:\Sites\www.mysite.com 
+0

請注意,這會刪除整個XML元素。 (這似乎是你想要的,但希望用Remove-WebConfigurationProperty去除*屬性的用戶可能會在這裏找到方法。) – jpmc26

相關問題