Archive for August 2008

Automatically Create IIS Application Pools

2008-08-28 by Administrator, tagged as microsoft, programming

Here is the script for the AppPools

@ECHO OFF
ECHO.
FOR /F "eol=# delims=; tokens=1,2*" %%f in (apppools.txt) DO (
  ECHO Creating AppPool "%%f" with user identity "%%g"
  CSCRIPT %SYSTEMDRIVE%\Inetpub\AdminScripts\ADSUTIL.VBS CREATE "w3svc/AppPools/%%f" IIsApplicationPool
  CSCRIPT %SYSTEMDRIVE%\Inetpub\AdminScripts\ADSUTIL.VBS SET "w3svc/AppPools/%%f/WamUserName" "%%g"
  CSCRIPT %SYSTEMDRIVE%\Inetpub\AdminScripts\ADSUTIL.VBS SET "w3svc/AppPools/%%f/WamUserPass" "%%h"
  CSCRIPT %SYSTEMDRIVE%\Inetpub\AdminScripts\ADSUTIL.VBS SET "w3svc/AppPools/%%f/AppPoolIdentityType" 3
  ECHO.
)
pause

And the correspondign text file:

#
# ";"-delimited file to create application pools
# Beware of strange characters in password,
# though ; should work 
# Structure is
#
# AppPool Name	;	User	;	Password
tmpAppPool;tmpUser;tmpPass

Automatically Create IIS Websites

2008-08-21 by Administrator, tagged as microsoft, programming

I had to create quite a lot websites on a Microsoft IIS webserver and of course there is a nice scripting solution to it. Here is how I did it:

Batch code:

@ECHO OFF
SET webRoot=D:\websites
ECHO.
ECHO Creating directories
ECHO and websites
ECHO.
FOR /F "eol=# delims=; tokens=1,2*" %%f in (websites.txt) DO (
	ECHO Creating Dir %webRoot%\%%f\%%g and website %%g in appPool %%h
	MD "%webRoot%\%%f\%%g"
	iisweb /create "%webRoot%\%%f\%%g" "%%g" /i 192.168.228.30 /d %%g.perimeterless.org /ap %%h
	ECHO.
)
pause

and here is the text file that goes with it:

#
# ";"-delimited file to create directory structure,
# websites and application pools
#
# Structure is
#
# Subdirectory	;	Sitename	;	AppPool
testing;test1;DefaultAppPool
testing;test2;DefaultAppPool
testing;test3;DefaultAppPool