Поделиться через


Setting SharePoint content databases offline via Script

Body:

If you followed the TechNet documentation for Set-SPContentDatabase and try to take SharePoint content databases offline by running Set-SPContentDatabase –Status Offline you will be really disappointed to know that it just does not work. If you look at the TechNet documentation, the type associated with Status is Microsoft.SharePoint.Administration.SPObjectStatus, valid values are “Online”, “Disabled”, “Offline”, “Unprovisioning”, “Provisioning”, “Upgrading” See this link for more information

Unfortunately passing none of the above values work. So I decided to look into the source of manage content database settings page by doing a view source in browser

cdbsettings

What I found in view source is valid values for Database Status is 0 and 1 as shown in screenshot below.

cdbsettings1

So to Take Content Database Offline you have to run the following script

Get-SPContentDatabase “{replace with name of content database}” | Set-SPContentDatabase –Status 1

Bring Content Database Back Online

Get-SPContentDatabase “{replace with name of content database}” | Set-SPContentDatabase –Status 0

Cheers,

</Ram>

Published: 5/9/2012 12:03 PM

Attachments: https://www.spmcm.me/Blog/Lists/Posts/Attachments/52/cdbsettings_2_4B51E2E4.png
https://www.spmcm.me/Blog/Lists/Posts/Attachments/52/cdbsettings_thumb_4B51E2E4.png
https://www.spmcm.me/Blog/Lists/Posts/Attachments/52/cdbsettings1_2_4B51E2E4.png
https://www.spmcm.me/Blog/Lists/Posts/Attachments/52/cdbsettings1_thumb_4B51E2E4.png