Thursday, January 30, 2014

How to use PowerShell console window title to monitor SharePoint 2013 upgrade status and timing?

PowerShell script is heavily used for SharePoint 2013 upgrade and also daily administration. We have automated almost all SharePoint 2013 upgrade activities using PowerShell. Developers normally write the SharePoint 2013 upgrade step status and timing into log file so we could tracking the progress and time spend. It would be helpful to provide feedback or status messages directly  to the PowerShell so person running the script could know what the script is doing.

There are a number of ways you can accomplish this such as using Write-Host, Write-Progress or Write-Verbose. The easy way is to use the title bar of the PowerShell console or ISE. Here is example to display the time spend on one of the SharePoint PowerShell command “Get-Get-SPSite -limit ALL”.

# Get current time
$startTime = [DateTime]::Now

# Execute any PowerShell script
Get-SPSite -limit ALL

# Calculate time spend
$totalTime = [DateTime]::Now - $startTime

# Set time spend in second as window title & display
$status = "Get-Get-SPSite -limit ALL spend " + $totalTime.TotalSeconds + " seconds"
$host.ui.RawUI.WindowTitle = $status

The result is displayed as in the following screen shot as Window title.

As best practice, you might need to store the default original window title in a variable and set back after your activities completed. You could use the following PowerShell scripts.

# Store original window title
$title = $host.ui.RawUI.WindowTitle

# Do something here

# Set back original window title
$host.ui.RawUI.WindowTitle = $title

Now, you should have the  PowerShell console directly display the upgrade status and timing for you in SharePoint 2013 upgrade.

Monday, January 27, 2014

How to prevent SharePoint always prompts for login credentials?

SharePoint always promptsfor login credentials and there are several blogs already covered the common issues as listed below.

When we upgrade out SharePoint from 2010 to 2013, we constantly run into issue that SharePoint 2013 always prompts for login credentials. The cause is not related to any of the issues listed above. Since we are follow up best practice using multiple system accounts on SharePoint 2013 upgrade, we found the most common root cause for the issue is spn is not set up on AD for the SharePoint system account. Here is the way to identify whether you have such issue.

Use the following command line to display the SharePoint system account whether it has the spn configured in AD.

setspn –l domain\SPAccount

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\harryc>setspn -l na\spdev1
Registered ServicePrincipalNames for CN=spdev1,OU=CORP,OU=Service Accounts,DC=na,DC=domain,DC=com:


What you should look are the following several things.

  1. Does SharePoint AAM all listed in the spn? If not, include all AAM in the spn
  2. Does other accounts have the same spn configured to SharePoint? If so, you should remove them and leave only one account associate with the SharePoint URL
  3. Does the IISReset done on each WFE? If not, IISReset on all WFEs to force SPN propogate to SharePoint servers
If you have the correct spn configured for SharePoint system account, there is high chance users will be able to login to SharePoint after enter user name and password no more than ONE time.

Tips to resolve SharePoint 2013 upgrade issues "Could not load file or assembly 'Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies."

After we migrated SharePoint from 2010 to 2013, we found several sites could not be displayed with the following error.

Sorry, something went wrong

Could not load file or assembly 'Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. The system cannot find the file specified.

After looking the welcome page URL for the site users try to hit. It’s something like http://servername.domain/site/default.aspx. However, this site is Wiki sites and the welcome page should be like http://servername.domain/site/SitePages/Home.aspx.

The workaround is to activate the “Wiki Page Home Page” web feature and the welcome page will default to http://servername.domain/site/SitePages/Home.aspx.

Please note if your site is not wiki site and you activate the Wiki Page Home Page” web feature, users my "lost" customizations on the home page. You could always deactivate the same feature to display the customized home page that is defined as welcome page for the site.

Also this is very obvious but we had so many users complain about the site home page and this might be handy to resolve the issue for end users.