I was assigned a task, recently, whereby I was given a list of about 100 domain names and I had to create all those websites on a fresh installation of IIS 6.0. Naturally, I started looking for some kind of tool that would do this for me. After spending some time on search and asking a few people, I realized , there is no such tool (correct me if I am wrong here).
So, I thought of writing a little ColdFusion script that would do this for me. Turns out it wasnt that bad at all and it worked like a charm.
Here is the script I wrote.
[xml]
<cfset sites = ["abc.com","xyz.com"] />
<!— I have removed the actual site names from the list above—>
<!— loop over all the sites—>
<cfloop from="1" to="#arraylen(sites)#" index="i">
<!— see if the site folder exists—>
<cfset thisSite = sites[i] />
<cfset site_path = "c:/websites/#thisSite#">
<cfif NOT DirectoryExists(site_path)>
<!— create if does not exist already—>
<cfdirectory action="create" directory="#site_path#" />
</cfif>
<!— construct the IIS site creation command—>
<cfset iis_cmd = "c:\windows\system32\" & ‘iisweb.vbs /create c:\websites\#thisSite# "#thisSite#" /i IP_ADDRESS_HERE /d #thisSite# ‘>
<cfexecute name="c:\windows\system32\cscript.exe" arguments="#iis_cmd#" timeout="30" variable="strResult" />
<cfdump var = "#strResult#">
</cfloop>
[/xml]
I took help from this article, which details the different attributes of the iisweb.vbs command-line utility.
Is this for 1 IP address for all the websites?
Yes I wanted it that way but you can change that to any IP or any host header.
iisweb.vbs does not exist on windows 2008. on win2008 use powershell with microsoft.web.administration and microsoft.web.management.
Radek, thanks for the info. I was actually using this on Win2003 Server. But if I happen to do it on 2008, I will keep this in mind. Hows it going these days ?
Thanks for sharing this script, it is very helpful.
You are amazing! Where did you learn to write such things??
Thank you for sharing!