#***** Start the Pools if found in Stopped State
Import-Module WebAdministration
$poolNames = Get-SPWebApplication | select @{Expression={$_.ApplicationPool.name};label="PoolName"}
foreach($i in $poolNames)
{
Write-host "Application Pool Name:" $i.poolName
$statusNow = Get-WebAppPoolState -name $i.poolName
if ($statusNow.Value -eq "Stopped")
{
Start-WebAppPool $i.poolName
Write-Host -ForegroundColor Red $i.poolName "Found in Stopped State : Starting the Pool"
}
else
{
Write-Host -ForegroundColor white $i.poolName "Already in Started State."
}
}
#*****Start the WebSite if found in Stopped State
Import-Module WebAdministration
foreach($i in Get-Website)
{
if ($i.State -eq "Stopped")
{
Start-Website $i.Name
Write-Host -ForegroundColor Red $i.Name "Site Found in Stopped State : Starting the WebSite"
}
else
{
Write-Host -ForegroundColor white $i.Name "Already in Started State."
}
}
No comments:
Post a Comment