Manage IIS And SharePoint Services In SharePoint 2010 Using PowerShell Script

In your day-to-day activities as a SharePoint Administrator, you always need to monitor the web sites and application pools in your SharePoint farm. Especially after the application deployments, I see there are many times these web sites and application pools stop in many servers and you need to login to each and every server to verify them and start them.

Here, I have developed the scripts given below, where you do not need to login to each server. You just need to login to any one server in a farm and execute the scripts given below, which will remotely verify the web sites and application pools and show you the results. There is also a possibility to start them, if anything is stopped in any server in the farm.

If you have a large SharePoint farm with multiple WFE Servers, it will be very helpful to manage from one server. You do not need to login to each server and manage them. You can save a lot of time.

Additionally, there are two scripts to restart IIS and SharePoint Services in the whole farm.  

Steps to follow

Login to any Server in the farm - > copy the attached zip file and extract it -> Open SharePoint 2010 Management Shell -> execute ps1 files given below.

Note- You will find Sam.Functions.ps1 file, which contains the functions definitions given below. It is the important file.

  • Get all the Application Pools, which are stopped in SharePoint 2010 farm.
    .\Sam.GetAppPoolStatusOnFarm.ps1

  • Start the Application Pools, which are stopped in SharePoint 2010 farm.
    .\Sam.StartStoppedAppPoolOnFarm.ps1

  • Get all the Websites, which are stopped in SharePoint 2010 farm.
    .\Sam.GetWebsitesStatusOnFarm.Ps1

  • Start all the Websites, which are stopped in the farm (if default Website is stopped in a server, then it will skip the Server).
    .\Sam.StartStoppedWebSitesOnFarm.ps1

  • Restart IIS in all the Servers in SharePoint 2010 farm.
    .\Sam.RestartIISOnFarm.ps1

  • Restart SharePoint Services in all the Servers in a SharePoint 2010 farm.
    .\Sam.RestartSharePointServicesOnFarm.ps1

Note

To start/restart scripts, it will ask to you confirm(yes/no) in PowerShell Window before it executes so that you can make a decision before executing them.

Hope you like it.

Please find an attached zip file, which contains all the script files and post your comment/feedback/questions.

X

Build smarter apps with Machine Learning, Bots, Cognitive Services - Start free.

Start Learning Now