Pages

Monday, November 5, 2012

SPContentDatabase Powershell Commands


New-SPContentDatabase
Creates a new content database and attaches it to the specified Web application.

C:\PS>New-SPContentDatabase "MyDatabase" -DatabaseServer "MyServer" -WebApplication http://sitename
This example creates a new content database for the sitename Web application.

Remove-SPContentDatabase
Deletes a content database.

C:\PS>Get-SPContentDatabase 12345678-90ab-cdef-1234-567890abcdef | Remove-SPContentDatabase
This example deletes the specified content database.

Get-SPContentDatabase
Returns one or more content databases.

C:\PS>Get-SPContentDatabase -webapplication http://sitename
This example returns all content databases used by the sitename Web application.

C:\PS>Get-SPContentDatabase -site http://contoso.com
This example returns the content database that contains the site collection at http://contoso.com.

Set-SPContentDatabase
Sets global properties of a SharePoint content database.

C:\PS>Get-SPContentDatabase http://contoso.com | Set-SPContentDatabase -MaxSiteCount 1
This example sets the MaxSiteCount for the content database that contains contoso.com to 1.

C:\PS>Get-SPContentDatabase -WebApplication http://sitename | Set-SPContentDatabase -WarningSiteCount $null
This example clears the WarningSiteCount for all databases in the sitename Web application.

Mount-SPContentDatabase
Attaches an existing content database to the farm.

C:\PS>Mount-SPContentDatabase "MyDatabase" -DatabaseServer "MyServer" -WebApplication http://sitename
This example mounts an already existing database to the sitename Web application.

Dismount-SPContentDatabase
Detaches a content database from its currently associated Web application.

C:\PS>Dismount-SPContentDatabase 12345678-90ab-cdef-1234-567890abcdef
This example detaches the content database with the GUID 12345678-90ab-cdef-1234-567890abcdef from its current parent Web application.

C:\PS>Get-SPContentDatabase -WebApplication http://sitename | Dismount-SPContentDatabase -WhatIf
This example detaches all content databases from the Web application on port 80 of the local machine. Remove the WhatIf parameter to perform the operation.

No comments:

Post a Comment