Powershell and SharePoint – Part 1

Powershell is just interesting. As and more I explore, I find many more possibilities with powershell. Recently was wowing when I learned that Unix commands can be brought in to Powershell by creating “Alias” commands.

Let us see some basic Powershell command-lets (cmdlets) related to Content database.

  • New-SPConfigurationDatabase
  • Connect-SPConfigurationDatabase
  • Disconnect-SPConfigurationDatabase
  • Remove-SPConfigurationDatabase

This cmdlet is used to create a new configuration database aka the SharePoint Farm which can be connected to the existing farm using the next Connect-SPConfigurationDatabase cmdlet.

New-SPConfigurationDatabase [-DatabaseName] [-DatabaseServer] [[-DirectoryDomain] ] [[-DirectoryOrganizationUnit] ] [[-AdministrationContentDatabaseName] ] [[-DatabaseCredentials] ] [-FarmCredentials] [-Passphrase] [-AssignmentCollection ]

There is a script given in technet which helps to create a complete new SP Farm. Tweak it a bit with your credentials and it is good to go
Create a new SharePoint Farm

This cmdlet is used to connect the current server to the specified configuration database. In other terms, we are configuring an existing database for the SharePoint server.

Connect-SPConfigurationDatabase [-DatabaseName] [-Passphrase] -DatabaseServer [-AssignmentCollection ] [-DatabaseCredentials ]

Again this is another helping script to attach a newly created SP Farm to the existing Farm. Tweak it a bit according to your credentials.
Join an existing Farm

As you can connect a new SharePoint farm to the existing farm, you can disconnect a SP Farm from an existing farm using Powershell. The Configuration Database must be removed before the Database can be removed. This command is only to remove and not to delete the Farm.

Disconnect-SPConfigurationDatabase [-AssignmentCollection ] [-Confirm []] [-WhatIf []]

To permanently delete the Configuration database the below cmdlet must be used. Before we try to delete the database, we should and must dismount the database by using the previous command.

Remove-SPConfigurationDatabase [-AssignmentCollection ] [-Confirm []] [-WhatIf []]

(Ref: Technet Site)


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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s