Dylan Beattie
Dylan Beattie

Reputation: 54140

What "Name" parameter must I specify to remove an IIS custom error using Remove-WebConfigurationProperty in Powershell?

Trying to use Powershell to script the removal of specific custom errors from an IIS website.

I have got this far:

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

but running that fails with a warning that:

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

I have no idea what to specify for the Name parameter here - and Remove-WebConfigurationProperty is woefully underdocumented... any ideas?

Upvotes: 1

Views: 1733

Answers (1)

Dylan Beattie
Dylan Beattie

Reputation: 54140

Ah... cracked it. It's not Remove-WebConfigurationProperty, it's Clear-WebConfiguration that's used in this context:

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

Upvotes: 5

Related Questions