I need to find a way to check if a Web Site and it's AppPool already exist. If so, then I need to install/update the Web Apps within the Web Site and recycle the App Pool. If they site and pool do not exist, then I need to create them, deploy the applications and start the App Pool. Below is what I've been trying to do in a .cmd file in IIS7. The problem is if I give it a website that doesn't exist, it still hits the "echo %_WebSiteName% Found!"
@echo off
cls
echo.
:NextArgument
set _ArgCurrentOriginal=%*
set _ArgCurrent=%~1
echo _ArgCurrentOriginal=%_ArgCurrentOriginal%
echo _ArgCurrent=%_ArgCurrent%
echo.
set _WebSiteName="%_ArgCurrent%"
echo _WebSiteName=%_WebSiteName%
echo.
echo appcmd list site %_WebSiteName% /text:name
echo.
set _AppCmdLine=appcmd list site %_WebSiteName% /text:name
call %_AppCmdLine% > websitename.txt
echo list file content
type websitename.txt
echo.
echo Load file content
set _FoundName=websitename.txt
echo.
echo _FoundName="%_FoundName%"
echo.
IF /I NOT("%_FoundName%"=="") (
echo %_WebSiteName% Not Found!
) else (
echo %_WebSiteName% Found!
)
echo.
pause
Sep 12 2011 by
jinkskgpt