Tuesday, April 14, 2015

Quiescing a SharePoint Farm

I recently had to move a set of SharePoint Content databases on my SQL Server because the Transaction Logs were getting too large and completely filled up the available disk space.

Well, when I attempted to detach the SQL Server databases, I could never successfully detach the databases because SharePoint was always maintaining at least 1 connection to the Content databases.

So what was I to do??

Well, fortunately, there is a SharePoint quiesce command that shuts down all of the SharePoint services.

However, this command is still reliant on the old stsadm command and does not yet have a PowerShell equivalent (even with SharePoint 2013).


Quiescefarm: Stsadm operation (Office SharePoint Server)
https://technet.microsoft.com/en-us/library/cc262797%28v=office.12%29.aspx

Unquiescefarm: Stsadm operation (Office SharePoint Server)https://technet.microsoft.com/en-us/library/cc261750%28v=office.12%29.aspx

The location of the stsadm executable on a SharePoint 2013 installation is: 

C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\BIN\STSADM.EXE

As soon as I quiesced my SharePoint Farm, I was able to successfully detach my SharePoint Content databases and move them to a new hard drive.

Once I was done with my Content database migration, I went ahead and ran the stsadm -o unquiescefarm command!
 
Of course, since I figured I would need to use these commands frequently for the foreseeable future, I decided to create my own PowerShell equivalents to save myself the trouble of resorting to the command line:
 
$STSADMPath = @"
"C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\BIN\STSADM.EXE"
"@
$MaxDuration = "60"
 
$STSQuiesceCmd = "cmd /c $STSADMPath -o quiescefarm -maxduration $MaxDuration"
Write-Host $STSQuiesceCmd
Invoke-Expression -Command $STSQuiesceCmd


$STSADMPath = @"
"C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\BIN\STSADM.EXE"
"@
 
$STSUnquiesceCmd = "cmd /c $STSADMPath -o unquiescefarm"
Write-Host $STSUnquiesceCmd
Invoke-Expression -Command $STSUnquiesceCmd

 






 

No comments:

Post a Comment