I'm trying to write a provisioning tool for our web application. I am attempting to create a web site remotely in IIS7.5 using Microsoft.Web.Administration.ServerManager.
CODE:
using (ServerManager serverManager = ServerManager.OpenRemote("MyRemoteHost")) { serverManager.Sites.Add("Contoso", "http", "*:80:www.contoso.com", @"C:\inetpub\wwwroot\Contoso"); serverManager.CommitChanges(); }
The above code continuously fails with error: Invalid index. (Exception from HRESULT: 0x80070585)
NOTES:
- If I run this code locally on the host, I do not encounter the error and the web site is created successfully.
- My user has administrative privileges on the remote host.
- I am able to perform other operations on the remote host such as reading the listing of sites.
- My workstation is running Windows 8
- I've managed to successfully execute the above mentioned code against a Server 2012 host. There appears to be some sort of incompatibility when running this code on a Windows 8 client against a Server 2008R2 host.
- I'm using Microsoft.Web.Administration.7.0.0.0.
Any help in resolving this issue would be greatly appreciated.
Thank you