This past week, I have had the need to work on changing the application pools in MOSS 2007. One of the web applications I work with needed to be isolated to prevent it from affecting other web applications that run in the same pool. Looking at the MOSS API documentation, this seemed to be fairly simple. Turns out it is not so simple after all.
I started this adventure by looking on the Internet for a starter script. I found one on this blog. This looked to be almost exactly what I was looking for. So I began to work in my test environment to get this to work. However, every time the script tried to run the SPWebApplication.ProvisionGlobally() method, the code generated an exception stating “Object not set to an instance of an object.” Looking at the test environment, I could see the web application had been moved on the local machine, but had not been touched on the other machine in the test Sharepoint farm.
After two days of testing and searching for what could be wrong, I found an entry on Connect at Microsoft. This is very similar to what I was seeing even though the code was slightly different. Please take a minute and vote this up to get a fix published.
I have an idea for a workaround and will post that if I can get a chance to test it in the next couple of days. I am thinking it may be possible to use Powershell Remoting to the remote server(s) and use the Provision() method instead. If you have had any experience with this or have a workaround that you have used, I would love to hear from you.