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