Как удалить site и pools из windows iis с помощью powershell.Deleting sites and application pools from Microsoft IIS using PowerShell

Удалить po0ls

#Deleting Sites and app pools in IIS 7 with PowerShell
$appCmd = "C:\windows\system32\inetsrv\appcmd.exe"

#lists all the sites
#& $appcmd list site 
#deletes a specific site
#& $appcmd delete site "Name of site"
#lists all the sites
#& $appcmd list apppool 
#deletes a specific application pool
#& $appcmd delete apppool "Name of app pool"
#delete any app pools that use a certain username (in the identity column of the GUI)
#$account = "TheDomain\TheAccount"
$AppPools = & $appcmd list apppool 
foreach ($pool in $AppPools){
    $pool = $pool.split(" ")[1] #get the name only
    & $appcmd delete apppool $pool
}
#delete all app pools that use a certain username except for a given app pool name
$account = "TheDomain\TheAccount"
$AppPools = & $appcmd list apppool /processModel.userName:$account
foreach ($pool in $AppPools){
    $pool = $pool.split(" ")[1] #get the name only
    if ($pool -ne "MyAppPool")
        {
            & $appcmd delete apppool $pool
        }
}

Удалить site

#Deleting Sites and app pools in IIS 7 with PowerShell
$appCmd = "C:\windows\system32\inetsrv\appcmd.exe"

#lists all the sites
& $appcmd list site 
#deletes a specific site
#& $appcmd delete site "Name of site"
#deletes a specific application pool
#& $appcmd delete apppool "Name of app pool"
#delete any app pools that use a certain username (in the identity column of the GUI)
#$account = "TheDomain\TheAccount"
$AppPools = & $appcmd list site # /processModel.userName:$account
foreach ($pool in $AppPools){
    $pool = $pool.split(" ")[1] #get the name only
    & $appcmd delete site $pool
}
#delete all app pools that use a certain username except for a given app pool name
#$account = "TheDomain\TheAccount"
$AppPools = & $appcmd list site #/processModel.userName:$account
foreach ($pool in $AppPools){
    $pool = $pool.split(" ")[1] #get the name only
    if ($pool -ne "MyAppPool")
        {
            & $appcmd delete site $pool
        }
}

 

Similar Posts:

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *