Powershell and SharePoint – Part 2


The cmdlets that will be discussed in Part 2 are

  • New-SPContentDatabase
  • Get-SPContentDatabase
  • Set-SPContentDatabase

New-SPContentDatabase
This cmdlet as it tries to imply, creates a new content database for a SharePoint web application. The minimum parameters that will be expected are ContentDatabase name and the WebApplication URL.

Syntax
New-SPContentDatabase [-Name] [-WebApplication] [-AssignmentCollection ] [-AssignNewDatabaseId ] [-ChangeSyncKnowledge ] [-ClearChangeLog ] [-Confirm []] [-DatabaseCredentials ] [-DatabaseServer ] [-MaxSiteCount ] [-WarningSiteCount ] [-WhatIf []]

Example:
$DBName = “ContentDB”
$WebApplicationURL = “http://gai3kannan.wordpress/”
New-SPContentDatabase -Name $DBName -WebApplication $WebApplicationURL

Get-SPContentDatabase
Get-SPContentDatabase is used to list down all the Content Database in a SharePoint farm. Below are four different types of usage for this command. The parameters within the below four options cannot be mixed as it will not be understood.

Syntax
Get-SPContentDatabase [[-Identity] ] [-AssignmentCollection ]
Get-SPContentDatabase -WebApplication [-AssignmentCollection ]
Get-SPContentDatabase -Site [-AssignmentCollection ]
Get-SPContentDatabase -ConnectAsUnattachedDatabase -DatabaseName -DatabaseServer [-AssignmentCollection ] [-DatabaseCredentials ]

Example:
The below command line is to get the database and it size in a SharePoint farm.
Get-SPContentDatabase | select. @{Expression={“$($_.DiskSizeRequired/1GB)GB”};Label=”Size”}

Set-SPContentDatabase
This cmdlet sets the existing content database to a new SharePoint Application. Can be used along with Get-SpContentDatabase or separately

Syntax
Set-SPContentDatabase [-Identity] [-AssignmentCollection ] [-Confirm []] [-MaxSiteCount ] [-Status ] [-WarningSiteCount ] [-WhatIf []]

Example:
There is a script in this link which gives an good example of Set-SpContentDatabase

More in Part 3…

Advertisements

About gai3kannan

I am working with NCS Pte Ltd as a Lead Consultant I have taken SharePoint as my full time action and thoughts.
This entry was posted in My Own Posts, Powershell with SharePoint 2010 and tagged , , , . Bookmark the permalink.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s