Twitter Feed
Tweets by SundownSolLtd

SharePoint 2013 Starting Services on Multiple Servers using PowerShell

7th August


These script blocks are intended to be used to start services on multiple servers as a time saving exercise. The three below are an example of endpoints that can be enabled across the whole farm but feel free to chop and change as necessary

#####################################################################################

#Initial Config

#Used to illustrate what servers the services should be started on - Uses a match on the first portion of server names to pull #back all FE's or App's as appropriate

#For instance if we have ten servers, 3 WFEs all called LIVEWIREWFE1,2,3 etc and 7 APP servers called #LIVEWIREAPP1,2,3 etc and we wanted to only start

#service on the WFEs - we would set the $CompName to LIVEWIREWFE - if we wanted to start the #services on only the app servers we would set it to LIVEWIREAPP

#if we wanted to start services across all servers then we would use LIVEWIRE

#####################################################################################

   

$CompName = "CONSP1"

   

####################################################################

######### Managed Meta Data Service - Starts on all Servers #################

####################################################################

   

Write-Host "Managed MetaData Service Endpoints BEFORE provisioning:"-foregroundcolor red -backgroundcolor yellow

get-SPServiceInstance |?{$_.TypeName -eq "Managed MetaData Web Service"}

$Servers = Get-SPServer | ?{$_.Address -Match $CompName}

foreach ($Server in $Servers)

{

Write-Host "Starting MMS Service Instance on " $Server -foregroundcolor red -backgroundcolor yellow

Get-SpServiceInstance -Server $Server |?{$_.TypeName -eq "Managed MetaData Web Service"} | Start-SPServiceInstance

}

Start-Sleep -s 5 #Sleeps for 5 seconds to allow provisioning to complete

Write-Host "Managed MetaData Service Endpoints AFTER provisioning:"-foregroundcolor red -backgroundcolor yellow

get-SPServiceInstance |?{$_.TypeName -eq "Managed MetaData Web Service"}

   

   

####################################################################

######### Secure Store Service - Starts on all Servers ########################

####################################################################

   

Write-Host "Secure Store Service Endpoints BEFORE provisioning:"-foregroundcolor red -backgroundcolor yellow

get-SPServiceInstance |?{$_.TypeName -eq "Secure Store Service"}

$Servers = Get-SPServer | ?{$_.Address -Match $CompName}

foreach ($Server in $Servers)

{

Write-Host "Starting Secure Store Service Instance on " $Server -foregroundcolor red -backgroundcolor yellow

Get-SpServiceInstance -Server $Server |?{$_.TypeName -eq "Secure Store Service"} | Start-SPServiceInstance

}

Start-Sleep -s 5 #Sleeps for 5 seconds to allow provisioning to complete

Write-Host "Secure Store Service Endpoints AFTER provisioning:"-foregroundcolor red -backgroundcolor yellow

get-SPServiceInstance |?{$_.TypeName -eq "Secure Store Service"}

   

####################################################################

######### BDC - Starts on all Servers ########################

####################################################################

   

Write-Host "BDC Endpoints BEFORE provisioning:"-foregroundcolor red -backgroundcolor yellow

get-SPServiceInstance |?{$_.TypeName -eq "Business Data Connectivity Service"}

$Servers = Get-SPServer | ?{$_.Address -Match $CompName}

foreach ($Server in $Servers)

{

Write-Host "Starting BDC Instance on " $Server -foregroundcolor red -backgroundcolor yellow

Get-SpServiceInstance -Server $Server |?{$_.TypeName -eq "Business Data Connectivity Service"} | Start-SPServiceInstance

}

Start-Sleep -s 5 #Sleeps for 5 seconds to allow provisioning to complete

Write-Host "BDC Endpoints AFTER provisioning:"-foregroundcolor red -backgroundcolor yellow

get-SPServiceInstance |?{$_.TypeName -eq "Business Data Connectivity Service"}

   

If you come get to the point where you want to stop all instances across all servers then feel free to use this:

$CompName = "<SERVER Name>"

$Servers = Get-SPServer | ?{$_.Address -Match $CompName}

foreach ($Server in $Servers)

{

Get-SpServiceInstance -Server $Server |?{$_.TypeName -eq "<INSERT SERVICE INSTANCE NAME>"} | Stop-SPServiceInstance

}

So there you have it – hopefully this will save a little time on your builds.

Follow Us