Saturday, May 21, 2016

PowerShell script to Manage Content Database in SharePoint

Hi Friends !!

There are few important PowerShell commands to Manage Content Database

1. PowerShell script to create new Content database

$User = "Database User login"
$PWord = ConvertTo-SecureString -String "Database login password" -AsPlainText -Force

$Credential = New-Object –TypeName System.Management.Automation.PSCredential –ArgumentList $User, $PWord

$WebApplication="Your SharePoint WebApplication Url"

New-SPContentDatabase "WSS_Content_Test" -DatabaseServer "Your Database server Instance name" -WebApplication $WebApplication -DatabaseCredentials $Credential

2. PowerShell Script to Attach/Detach Content Database with Web Application in SharePoint 


#Attach Content Database

$WebApplication="Your SharePoint WebApplication Url"


Mount-SPContentDatabase "WSS_Content_Test" -DatabaseServer "Database Server Instance Name" -WebApplication $WebApplication


#Below command will Detach Content Database from Web Application
Dismount-SPContentDatabase -Identity "WSS_Content_Test" 


#Below command will Detach Content Database from Web Application and drop the
# database from SQL Server 


Remove-SPContentDatabase -Identity "WSS_Content_Test" 

Note : Please be careful while using Remove script and scripting content databases.


Thanks 



1 comment:

  1. I blog frequently and I really value your substance. The article has really crested my advantage. I will take a note of your site and continue checking for new data about once every week.You know, many persons are looking round for this information, you could help them greatly.
    essay writing service

    ReplyDelete