I would like to add new bindings to a site using appcmd but I need to see if it exists first. How can I do so using AppCMD?
Much appreciated!
I would like to add new bindings to a site using appcmd but I need to see if it exists first. How can I do so using AppCMD?
Much appreciated!
You can create a batch file with the following code :
@ECHO OFF
SET appcmd=CALL %WINDIR%\system32\inetsrv\appcmd
%appcmd% list site /name:"Default Web Site"
IF "%ERRORLEVEL%" EQU "0" (
ECHO EXISTS
REM Add your bindings here
) ELSE (
ECHO NOT EXISTS
)
Here's the PowerShell way:
$exists = (&$appcmd list apppool /name:'MyApplicationPool') -ne $null
if ($exists -eq $false)
{
Write-Host 'App Pool does not exist'
}
else
{
Write-Host 'App Pool exists'
}
You can specify the site.name and do that in one line with the command line : "%systemroot%\system32\inetsrv\AppCmd.exe" list apps /path:"/PORTALSiteName" /site.name:"Default Web Site" && ECHO EXISTS
© 2022 - 2024 — McMap. All rights reserved.