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 



2 comments:

  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
  2. When people learn the language, they often view it as a task, rather than a privilege. Hence, using English becomes a necessity - a requirement to be used only for job interviews and other formal situations, rather than a special skill that may be utilized at any time of the day. However, you should realize that there are plenty of ways in which knowing English can benefit your day-to-day life.spin rewriter review

    ReplyDelete

SharePoint Deployment Error : The specified path, file name, or both are too long.

Hi, Sometimes we get surprised with below error while deploying wsp file... Solution : To overcome with this issue, we just ne...