30 June 2011

Shutdown Services Script for Sharepoint

Based on the blog post by Rafelo "Stopping and Restarting WSS 3.0 and Microsoft Office SharePoint 2007 (MOSS)" I wrote a quick cmd script to automate the hunt-and-peck task of shutting each of these SharePoint services down one by one.

net stop w3svc
net stop iisadmin
net stop ssosrv
net stop DCLauncher
net stop DCLoadBalancer
net stop OSearch
net stop SPAdmin
net stop SPSearch
net stop SPTimerV3
net stop SPTrace
net stop SPWriter
iisreset /stop

Why ever would we do this? In my case, I'm refreshing the content in the pre-production environment with the production content - and using a database restore of the related content databases to do this. SQL Server requires exclusive access to the database in order to overwrite it from a backup, so this is a pretty good way to drop all connections from the SharePoint IIS webserver.
And here is the script to bring it all back up (in the opposite order)
iisreset /start
net start SPWriter
net start SPTrace
net start SPTimerV3
net start SPSearch
net start SPAdmin
net start OSearch
net start DCLoadBalancer
net start DCLauncher
net start ssosrv
net start iisadmin
net start w3svc
Making the mundane a trifle less mundane, one script at a time.