We are in the process of moving over 100 domains over to a new server. I have created a script that will allow adding a Website entry and FTP entry into IIS 7 using a simple BAT file. I found several tutorials using AppCmd ADD SITE which works very well. By running :: c:\scripts\createIIS.bat youdomainname.com . Any feed-back? - It is working.
@Echo off
:: --------------------------------------------
:: Create IIS 7 Site Entry / FTP Site
:: --------------------------------------------
:: Get variable from command %1 Root Domain Name.
set rootDomainName = %1
:: This is the path to the Web Pages on the server.
set WebFile=C:\websites\
:: ADD NEW Directory
MKDIR %WebFile%%1
:: ADD IIS ENTRY
%windir%\system32\inetsrv\AppCmd ADD SITE /name:%1 /bindings:http/*:80:%1,http/*:80:www.%1 /physicalPath:C:\websites\%1
:: --------------------------------------------
:: CREATE FTP in IIS
:: --------------------------------------------
%windir%\system32\inetsrv\AppCmd add vdir /app.name:"Default FTP Site/" /path:/%1 /physicalPath:"%WebFile%%1"
echo New Directory Created: %WebFile%%1
echo IIS Website Created: %1 and www.%1
echo FTP SITE Created: %1
echo ...
echo ...
echo COMPLETED!
pause
Navigate to Start > Control Panel > Administrative Tools > Internet Information Services (IIS) Manager. Once the IIS console is open, expand the local server. Right-click on Sites , and click on Add FTP Site . In the Binding and SSL Settings window, type the IP address of the server.
Great script. Even though this isn't really a question, I modified it somewhat for batch processing.
First, I created a batch file that reads in a text file of websites to add, that references your slightly modified batch file to only create websites (no FTP's required):
@Echo off
:: ---------------------------------------------------------------------------------------
:: Create Batched IIS 7 Site Entries
::
:: Usage: CreateIISEntry.bat [websitename.com] (no www.)
::
for /f %%X in (NewWebsiteEntries.txt) do CreateSingleIISEntry.bat %%X
echo ...
echo *** BATCH PROCESS HAS BEEN COMPLETED ***
NewWebsiteEntries.txt contains a list of websites to create - one per line (no www. included):
site1.com
site2.com
site3.com
Lastly, the batch file that creates the entries:
@Echo off
:: ---------------------------------------------------------------------------------------
:: Create IIS 7 Site Entry
::
:: Usage: CreateSingleIISEntry.bat [websitename.com] (no www.)
:: ---------------------------------------------------------------------------------------
:: Get variable from command %1 Root Domain Name.
set rootDomainName = %1
:: This is the path to the Web Pages on the server.
set WebFile=C:\inetpub\wwwroot\
:: ADD NEW Directory
MKDIR %WebFile%%1
echo New Directory Created: %WebFile%%1
xcopy C:\inetpub\wwwroot\NewWebsiteHolding\*.* %WebFile%%1
:: ADD IIS ENTRY
%windir%\system32\inetsrv\AppCmd ADD SITE /name:%1 /bindings:http/[YOUR IP ADDRESS OR *]:80:%1,http/[YOUR IP ADDRESS OR *]:80:www.%1 /physicalPath:%WebFile%%1
echo IIS Website Created: %1 and www.%1
#:: --------------------------------------------
#:: CREATE FTP in IIS
#:: --------------------------------------------
#%windir%\system32\inetsrv\AppCmd add vdir /app.name:"Default FTP Site/" /path:/%1 /physicalPath:"%WebFile%%1"
#
#
#echo FTP SITE Created: %1
echo ...
echo ...
echo New website added ========================= %1
Since in my case, not all the new sites will be live at once, I a default placeholder site who's contents are copied into the newly-created website directories.
This will add all sites to the default app pool.
That's about it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With