A useful PowerShell script for checking services for SMSP and SharePoint

I ran into a timing problem when starting up virtual machines and when my LUNs where available to the hosts for all of my services for SnapManager for SharePoint and Microsoft SharePoint Server 2013 to start properly; so I put together this Windows PowerShell script that can be run on any host to check the different services that are required for SMSP and SharePoint.

 

Here is a quick list of the different services that are required:

  • Microsoft SQL Server (MSSQLSERVER)
  • SnapDrive (SWsvc)
  • SnapDrive Management Service (SDMgmtSvc)
  • Microsoft iSCSI Initiator Service (MSiSCSI)
  • IIS Admin Service (IISADMIN)
  • World Wide Web Publishing Service (W3SVC)
  • AppFabric Caching Service (AppFabricCachingService)
  • SharePoint Administration (SPAdminV4)
  • SharePoint Timer Service (SPTimerV4)
  • SharePoint Search Host Controller (SPSearchHostController)
  • SharePoint Server Search 15 (OSearch15)
  • SharePoint Tracing Service (SPTraceV4)
  • SMSP 7 Agent Service (DocAve 6 Agent Service)
  • SMSP 7 Media Service (DocAve 6 Media Service)
  • SMSP 7 Timer Service (DocAve 6 Timer Service)
  • DocAve 6 Report Service (DocAve 6 Report Service) -- Optional, only if you are using the Reporting Module from AvePoint in SMSP.

 

Only things necessary to edit based on your farm topology are the parameters for $sql, $wfe1, $wfe2 and $app. You may need to add a few other variables if you have clustered SQL Server, more WFEs, more Application Servers,etc.

 

# +---------------------------------------------------------------------------

# | File : Check-Services.ps1

# | Version : 1.00                                      

# | Purpose : Check key services for SnapManager for SharePoint and SharePoint Server 2013.

# | Usage : .\LodCreateSMSPVSM.ps1

# +----------------------------------------------------------------------------

# | Maintenance History                                           

# | --------------------                                           

# | Name Date         Version  C/R Description       

# | ----------------------------------------------------------------------------------

# | Rob Barker 2013-07-26   1.00          Created script.

# |

# +-------------------------------------------------------------------------------

# ********************************************************************************

 

Param (

  $sql = 'SQL1'

, $wfe1 = 'WFE1'

, $wfe2 = 'WFE2'

, $app = 'APPMED1')

 

function global:CheckServiceStatus([string]$server, [string]$service)

{

    $status = (Get-Service $service -ComputerName $server).Status

    $displayname = (Get-Service $service -ComputerName $server).DisplayName

 

    if ($status -eq "Running")

    {

        Write-Host $displayname "is " -ForegroundColor White -NoNewline; Write-Host "Running" -ForegroundColor Green

    } Else {

        if ($status -eq "Stopped")

        {

            $answer = Read-Host $displayname "is Stopped. Would you like to start this service? (Y/N)"

            if ($answer -eq 'Y')

            {

                (Get-Service $service -ComputerName $server).Start()

                CheckServiceStatus $server $service

            } Else {

                Write-Host "You will need to go to the $server server to start this service manually."

            }

        }

    }

}

cls

Write-Host "Checking all service statuses on $sql (SQL Server)"

CheckServiceStatus $sql "MSSQLSERVER"

CheckServiceStatus $sql "DocAve 6 Agent Service"

CheckServiceStatus $sql "SWSvc"

CheckServiceStatus $sql "SDMgmtSvc"

CheckServiceStatus $sql "MSiSCSI"

 

Write-Host

Write-Host "Checking all service statuses on $wfe1 (Web Front-End Server)"

CheckServiceStatus $wfe1 "AppFabricCachingService"

CheckServiceStatus $wfe1 "DocAve 6 Agent Service"

CheckServiceStatus $wfe1 "IISADMIN"

CheckServiceStatus $wfe1 "SPAdminV4"

CheckServiceStatus $wfe1 "SPTraceV4"

CheckServiceStatus $wfe1 "W3SVC"

 

Write-Host

Write-Host "Checking all service statuses on $wfe2 (Web Front-End Server)"

CheckServiceStatus $wfe2 "AppFabricCachingService"

CheckServiceStatus $wfe2 "DocAve 6 Agent Service"

CheckServiceStatus $wfe2 "IISADMIN"

CheckServiceStatus $wfe2 "SPAdminV4"

CheckServiceStatus $wfe2 "SPTraceV4"

CheckServiceStatus $wfe2 "W3SVC"

 

Write-Host

Write-Host "Checking all service statuses on $app (SharePoint Application Server)"

CheckServiceStatus $app "AppFabricCachingService"

CheckServiceStatus $app "DocAve 6 Agent Service"

CheckServiceStatus $app "DocAve 6 Media Service"

CheckServiceStatus $app "DocAve 6 Timer Service"

CheckServiceStatus $app "SWSvc"

CheckServiceStatus $app "SDMgmtSvc"

CheckServiceStatus $app "MSiSCSI"

CheckServiceStatus $app "DocAve 6 Report Service"

CheckServiceStatus $app "IISADMIN"

CheckServiceStatus $app "W3SVC"

CheckServiceStatus $app "SPSearchHostController"

CheckServiceStatus $app "OSearch15"

CheckServiceStatus $app "SPAdminV4"

CheckServiceStatus $app "SPTimerV4"

CheckServiceStatus $app "SPTraceV4" 

 

Hope it helps someone else out there!

 

Cheers,

@NaSharePointGuy