Tag Archives: Connection String

How to tips for SharePoint 2010 or Sharepoint 2013

This is more of a “Note to Self” entry with four quick tips I found myself looking for quite often in the last couple of weeks.

If you happen to have stumbled on this post, you probably are looking for the same thing, so Enjoy!

  • How to retrieve a list of master pages for all sites in a web application
  • How to retrieve the SharePoint connection sting, which will also list the name of the configuration database associated with your farm. Extremely helpful if you have more than one configuration database setting in the same SharePoint environment, which happens not to be yours!
  • How to reset the SharePoint passphrase for SharePoint, since you can’t retrieve it in PowerShell [to my knowledge]
  • How to grant site collection administrator right to all site collections

So here we go:

How to retrieve a list of master pages for all sites in a web application

Run this PowerShell command on the SharePoint application server

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Get All site collections

$SiteCollections = Get-SPWebApplication | Get-SPSite -Limit All

#Loop through all site collections

foreach($Site in $SiteCollections)

{

#Loop throuh all Sub Sites

foreach($Web in $Site.AllWebs)

{

$MasterPage = $Web.GetFile($Web.MasterUrl);

$MasterPage.Name  +” : ” +$Web.Url

}

}

How to retrieve the SharePoint connection string, which will also list the name of the configuration database associated with your farm

From the SharePoint application server

  • Open regedit [Start > Run > “regedit”]
  • Navigate to [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\14.0\Secure\ConfigDB]
  • Open the [dsn] key.
  • It should look something like this.
  • Data Source=sp2010srv;Initial Catalog=SharePoint_Config;Integrated Security=True;Enlist=False;Connect Timeout

How to reset the SharePoint passphrase for SharePoint, since you can’t retrieve it in PowerShell

Run the following PowerShell from the SharePoint application server

  • Enter the following prompt: $passphrase = ConvertTo-SecureString -asPlainText –Force
  • Input the new passphrase and hit enter
  • Enter this at the PowerShell prompt: Set-SPPassPhrase -PassPhrase $passphrase -Confirm
  • You will be asked to confirm the passphrase by re-entering it
  • Re-enter the passphrase and hit enter
  • You will be asked if you are sure that you want to perform this action. Type Y for yes and hit enter
  • Your farm passphrase is now reset

How to grant site collection administrator right to all site collections

Run the following PowerShell from the SharePoint application server

$scadmin = “domain\user”

$Sites = Get-SPsite

foreach ($site in $Sites) {

Set-SPSite -Identity $site -SecondaryOwnerAlias $scadmin

}