Remove-WebConfigurationProperty not removing file extension in request filtering section of IIS

92 views Asked by At

Getting below error message when trying to remove duplicate file extensions from request filtering section of a web application in IIS using Remove-WebConfigurationProperty powershell command.

Remove-WebConfigurationProperty : Filename: \\?\\C:\\Program Files (x86)\\MySite\\web.config
Line number: 167
Error: Cannot add duplicate collection entry of type 'add' with unique key attribute 'fileExtension' set to '.PNG'
At line:1 char:1

+ Remove-WebConfigurationProperty  -PSPath 'IIS:\\sites\\MySite' -Filte ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Remove-WebConfigurationProperty], COMException
    + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Microsoft.IIs.PowerShell.Provider.RemoveConfigurationPropertyCommand
  
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The powershell command that I tried executing is as below :

Remove-WebConfigurationProperty  -PSPath 'IIS:\\sites\\MySite' -Filter "system.webServer/security/requestFiltering/fileExtensions" -Name "." -AtElement @{ fileExtension= '.PNG' }

I was expecting this command to remove the duplicate entry but instead it ended up with the error message as mentioned above. Any leads on how to get it resolved will definitely help.

Thanks in advance

0

There are 0 answers