SharePoint Powershell cmdlet
Set-SPContentDatabase sets global properties of a SharePoint content database.
According to Microsoft Documentation:
Set-SPContentDatabase [-Identity] [-AssignmentCollection ] [-Confirm []] [-MaxSiteCount ] [-Status ] [-WarningSiteCount ] [-WhatIf []]
My troubles started when trying to update the Content Database status from Ready to Offline. As you can see above,
Status is supposed to accept the parameters:
Online | Disabled | Offline | Unprovisioning | Provisioning | Upgrading. So I tried:
Set-SPContentDatabase SP_ContentDB -Status Offline
This appeared to have worked as I didn’t receive an error.
Next I browsed to Central Admin | Manage Content Databases then selected the web application. The status of SP_ContentDB content database was error?
As I wanted to be able to script this change as part of a bigger more complex build process, I continued to try different things. I uncovered that passing in a 0 or 1 changes the status from Ready to Offline.
To change the content database status to
Ready: Set-SPContentDatabase SP_ContentDB -Status 0
To change the content datbaase status to
Offline: Set-SPContentDatabase SP_ContentDB -Status 1
This article was written by Sam Krueger. It is currently moderated by Mark Rentmeester.