Labels

2013-09-19

Powershell WebAdministration and case sensitivity for web applications


There is a caveat when working with IIS and WebAdministration module in Powershell: You must be careful if you create physical directories under your sites' physical root. If they mismatch, you will not be able to remove the web application again.

I've only experienced this on my Windows 7 with IIS 7, I'm not sure how it will work on higher versions of any of these products.

Here is a replication of the problem, follow these steps to reproduce.

> mkdir C:\inetpub\wwwroot\foobar
> New-WebApplication -Site "Default Web Site" -Name FooBar -PhysicalPath C:\inetpub\wwwroot\foobar 
dir 'IIS:\Sites\Default Web Site'
Remove-WebApplication -Name FooBar -Site "Default Web Site"
> dir 'IIS:\Sites\Default Web Site'
> rmdir C:\inetpub\wwwroot\foobar
Remove-WebApplication -Name FooBar -Site "Default Web Site"
mkdir C:\inetpub\wwwroot\foobar
> New-WebApplication -Site "Default Web Site" -Name foobar -PhysicalPath C:\inetpub\wwwroot\foobar 
dir 'IIS:\Sites\Default Web Site'
Remove-WebApplication -Name foobar -Site "Default Web Site"
dir 'IIS:\Sites\Default Web Site'