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.
<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>
I took help from this article, which details the different attributes of the iisweb.vbs command-line utility.
#1 by Tunc on January 16, 2010 - 1:24 pm
Quote
Is this for 1 IP address for all the websites?
#2 by Anuj Gakhar on January 16, 2010 - 1:35 pm
Quote
Yes I wanted it that way but you can change that to any IP or any host header.
#3 by rad_g on January 20, 2010 - 12:56 pm
Quote
iisweb.vbs does not exist on windows 2008. on win2008 use powershell with microsoft.web.administration and microsoft.web.management.
#4 by Anuj Gakhar on January 20, 2010 - 12:59 pm
Quote
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 ?