Inconvenient Settings Loss With Dismount-SPContentDatabase

Are you someone that likes to go through your web applications and dismount your databases prior to patching? Or maybe you’re just moving a content database from one web application to another. Or maybe, just maybe, you want to dismount a content database for the fun of it!

Well, if that’s you, you might have noticed (or maybe not), that when the content database is remounted, a few properties get reset to their default values such as MaximumSiteCount and WarningSiteCount (2,000 and 5,000 respectively). This can be pretty inconvenient (to say the least!) if you’ve modified these settings in any way and even more inconvenient if you didn’t document them before running Dismount-SPContentDatabase.

Once again, it’s our friend PowerShell to the rescue. The following functions allow you to dismount all of the content databases in a given web application (Dismount-SPContentDatabases) while retaining the pertinent settings in CSV file. The function helpfully titled Mount-SPContentDatabases will remount the content databases (using Mount-SPContentDatabase) to the supplied web application using the previous settings (including the original DatabaseServer), thus saving you at least 5 minutes to enjoy an additional cup of coffee.

Example Use

Imagine you have a web application with the name ContosoIntranet.

Export a Term Set to CSV with Identifiers in PowerShell

I recently had a need to export all of the terms from a given term set in a SharePoint 2010 Managed Metadata Service application to CSV for consumption in another process. The following PowerShell script will create a .csv file with all of the term names and identifiers for the supplied Term Store/Term Store Group/Term Set.

Updated: There was an error in the previous version of this script. It did not account for the fact that the ampersand character (“&”) is stored as a fullwidth ampersand (“\uFF06”) when a term is created. The script has been adjusted to replace any fullwidth ampersands with a basic Latin ampersand in the output.

The Script

Critical Path Training - 14 Free Webinars

Critical Path Training has just announced that they are offering 14 free webinars in the coming months focused on SharePoint 2010. If you’re looking for a solid introduction to SharePoint 2010, this is as good an opportunity as any.

Reference

SharePoint 2010 Products scripted deployment

It seems I missed it when Microsoft published the SPModule PowerShell module to aid in a scripted installation of a SharePoint 2010 farm.

If anything, it can serve as a handy guide for how to script out individual actions pertaining to installation and farm maintenance.

Reference

SharePoint 2010: Provisioning a new Farm with Powershell

SharePoint 2007 always required some level of scripting in it’s installation to allow for greater control of the installation process (i.e. creating database names without GUIDs). SharePoint 2010 is not any different in that scripting is still required to gain the finer control over installation. What has changed is that now PowerShell can be used in place of psconfig/stsadm. With that in mind, let’s begin.

  1. Install the SharePoint binaries on each server in your farm. Select “Complete” as the installation type. This will allow you to create a farm as opposed to a single server installation.After the install has completed, you will asked if you would like to complete the “SharePoint Products Configuration Wizard”. Do not run the wizard at this time.
  2. On the server which you wish to provision Central Administration:
    1. Open the  ”SharePoint 2010 Management Shell” (right-click and select “Run as administrator”). The shell will load with a message that the local farm is not accessible. This is expected as we have only installed the binaries.
    2. Run the following command to create the initial configuration/content database for the farm.
      
      New-SPConfigurationDatabase –DatabaseName “SharePoint2010_Config” –DatabaseServer “SharePoint2010SQL” –AdministrationContentDatabaseName “SharePoint2010_Content_Admin” –Passphrase (ConvertTo-SecureString “Pass@word1” –AsPlaintext –Force) –FarmCredentials (Get-Credential)
      

    3. After the initial creation of the farm, close and reload the “SharePoint 2010 Management Shell”. You should no longer receive any error messages.
    4. Install the help files.
      
      Install-SPHelpCollection -All
      

    5. Secure the resources used by the server (files and registry).
      
      Initialize-SPResourceSecurity
      

    6. Install and provision the farm services.
      
      Install-SPService
      

    7. Install the features on the server.
      
      Install-SPFeature –AllExistingFeatures
      

    8. Provision Central Administration.
      
      New-SPCentralAdministration -Port 1234  -WindowsAuthProvider "NTLM"
      

    9. Install the application content.
      
      Install-SPApplicationContent
      

    10. Optional: Disable the loopback check. If this is a development install, outright disabling the check should be fine. For production environments, the loopback check should be left in place and BackConnectionHostNames should be used in its place. See KB 896861.
      
      New-ItemProperty HKLM:\System\CurrentControlSet\Control\Lsa -Name "DisableLoopbackCheck"  -value "1" -PropertyType dword
      

  3. On each additional server that you wish to converge in the farm:
    1. Open the  ”SharePoint 2010 Management Shell” (right-click and select “Run as administrator”). The shell will load with a message that the local farm is not accessible. This is expected as we have only installed the binaries.
    2. Connect the server to the farm with the following command:
      
      Connect-SPConfigurationDatabase -DatabaseName "SharePoint2010_Config" -DatabaseServer "SharePoint2010SQL" -Passphrase (ConvertTo-SecureString "Pass@word1" -AsPlaintext -Force)
      

    3. Install the help files.
      
      Install-SPHelpCollection -All
      

    4. Secure the resources used by the server (files and registry).
      
      Initialize-SPResourceSecurity
      

    5. Install and provision the farm services.
      
      Install-SPService
      

    6. Install the features on the server.
      
      Install-SPFeature –AllExistingFeatures
      

    7. Install the application content.
      
      Install-SPApplicationContent
      

    8. Optional: Disable the loopback check. If this is a development install, outright disabling the check should be fine. For production environments, the loopback check should be left in place and BackConnectionHostNames should be used in its place. See KB 896861.
      
      New-ItemProperty HKLM:\System\CurrentControlSet\Control\Lsa -Name "DisableLoopbackCheck"  -value "1" -PropertyType dword
      

Reference

SQL server at DATABASESERVER has an unsupported version 10.0.2531.0

Attempting to run the SharePoint 2010 Configuration Wizard through PowerShell (New-SPConfigurationDatabase) yielded the following error:

New-SPConfigurationDatabase : SQL server at CLSHPT2010SQL has an unsupported version 10.0.2531.0. Please refer to “http://go.microsoft.com/fwlink/?LinkId=165761” for information on the minimum required SQL Server versions and how to download them.
At line:1 char:28

I had never installed the latest cumulative update for SQL Server 2008 after completing my cluster configuration. The fix is simple. Install the Cumulative update package 2 for SQL Server 2008 Service Pack 1 (KB970315).

Reference

User Profile Sync and Offline Content Databases

After a recent farm migration, a number of content databases were left offline. This had the unintended consequence of not allowing user profile synchronization to occur across site collections (where the content databases were offline).

The quick fix? Bring the content database(s) online.

The moral of the story? Do not leave your content database(s) offline without a good reason. If you do leave them offline, User Information Lists in the offline site collections will not be synchronized with the SSP.