About Me

SharePoint Architect with over 17 years of IT Experience in various roles as SharePoint Architect, Administrator, Technical Architect, IT Analyst, Application Developer, CRM Consultant, BI Developer, Microsoft Solution Architect in Client/Server, Web and Enterprise CRM Applications in E-Commerce, Financial, Healthcare, Insurance, Telecom, Outsourcing and Technology Services.
MCITP (Pro): Microsoft Certified IT Professional: SharePoint 2010 Administrator.
MCTS: Microsoft Certified Technology Specialist, SharePoint 2010 Configuration.

Monday, October 24, 2011

Start Pools or Websites if found in Stopped State

#***** 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