Cannot commit configuration changes because the file has changed on disk Cannot commit configuration changes because the file has changed on disk powershell powershell

Cannot commit configuration changes because the file has changed on disk


There are many different things that can lock the applicationHost.config file and cause powershell commands like New-IISSite to fail.

In this case, you mentioned you deleted the site manually so perhaps you still have IIS Manager open and it is locking the file. I suggest closing IIS Manager.

As described in this blog post on Powershell and IIS, the makers of Octopus Deploy have found that the only reliable solution to the file-locking problem is to wrap any file-altering commands like New-WebAppPool in try-catch blocks and retry these operations multiple times. The source code for a function to do this is found in the blog.


It seems something really screwy is going on with New-IISSite command. I ended up dropping back to New-Website (via WebAdmistration module), and all the problems went away.