Monday, November 30, 2015

SharePoint : Update URLs after resotring a content DB of hostnamed site collections

To change or update URLS after resotring a content DB of hostnamed site collections, use
stsadm -o renamesite -oldurl -newurl

You only need to rename the root hostnamed site collection. It will reflect on the other HNSC starting with the same URL.

If you try using Set-SPSiteURL on an HNSC with  same starting url, you will get the error : Could not perform this operation on the site collection To add a URL for this site collection add a URL to the root host-named site collection at At line:1 char:1

Wednesday, November 25, 2015

SharePoint : To search for "Everything" as the default option

To search for "Everything" as the default option, change search navigation settings under site settings > search settings, and add the following links

This Site

Wednesday, October 7, 2015

Correct way to handle exception for Get-SPWeb and Get-SpSite SharePoint PowerShell

Catch block does not work correctly for exceptions from get-spweb and get-spsite without the
-ErrorAction Stop parameter.

 This code will not print "in catch block"

 try{Get-SPWeb 'wrong url'} catch { Write-Host "in catch block" }

 correct usage : try{Get-SPWeb 'wrong url' -ErrorAction Stop } catch { Write-Host "in catch block" }

Monday, September 28, 2015

Access Host Web from App web in SharePoint hosted app - Office 365

Here is a snippet to save your day.
There are many snippets out there showing you how to do cross domain calls, but none of them complete.

Here is a sample to access host web components from a SharePoint hosted app or add in.
Keywords: SharePoint, access host web, sharepoint online, JSOM, CSOM, SharePoint hosted app, Office 365.

'use strict';

var hostweburl;
var appweburl;

var context;
var appContextSite;
var factory;

var context = SP.ClientContext.get_current();
var appContextSite;  
var rootweb ;
var roleDefinitions ; 

(function () {

 $(document).ready(function () {
     hostweburl = decodeURIComponent(getQueryStringParameter("SPHostUrl"));
     appweburl = decodeURIComponent(getQueryStringParameter("SPAppWebUrl"));
     var scriptbase = hostweburl + "/_layouts/15/";
     $.getScript(scriptbase + "SP.Runtime.js",
        function () {
      $('#message').append(" Getting Scripts.. 
            $.getScript(scriptbase + "SP.js",
                function () { $.getScript(scriptbase + "SP.RequestExecutor.js", loadRoleDefinition); }

 // This function prepares, loads, and then executes a SharePoint query 
 function loadRoleDefinition() {
  context = new SP.ClientContext(appweburl);
     factory = new SP.ProxyWebRequestExecutorFactory(appweburl);
     appContextSite = new SP.AppContextSite(context, hostweburl);
  rootweb = appContextSite.get_web();
  roleDefinitions = rootweb.get_roleDefinitions();
  context.executeQueryAsync(onGetRoleDefinitionSuccess, onGetRoleDefinitionFail);

 function onGetRoleDefinitionSuccess() {
  var permissionExists = false;
  var roleDefinitionsEnum = roleDefinitions.getEnumerator();
  while (roleDefinitionsEnum .moveNext()) {
   var temp = roleDefinitionsEnum.get_current();
   $('#message').append(temp.Name + " 

 function onGetRoleDefinitionFail(sender, args) {
  $('#message').text('Failed to get Role Definitions. Error:' + args.get_message());

Thursday, September 17, 2015

The best way to print out powershell exception details

Thanks to this blog, I learnt the best way to print out powershell exception details.

$_.Exception|format-list -force

Wednesday, September 9, 2015

Azure Active Directory GraphClient AuthorizationException

Error : Microsoft.Azure.ActiveDirectory.GraphClient.AuthorizationException Insufficient privileges to complete the operation


Under Configure
under Permissions to other applications

Add application - Windows Azure Active Directory
Give the following permissions

Read directory data
Sign in and read user profile

Stack Trace : 

Microsoft.Azure.ActiveDirectory.GraphClient.AuthorizationException was unhandled by user code
  Message=Insufficient privileges to complete the operation.
  ErrorMessage=Insufficient privileges to complete the operation.
       at Microsoft.Azure.ActiveDirectory.GraphClient.ConnectionWrapper.InvokeNetworkOperation[T](Func`1 action)
       at Microsoft.Azure.ActiveDirectory.GraphClient.ConnectionWrapper.DownloadData(String address, WebHeaderCollection additionalHeaders)
       at Microsoft.Azure.ActiveDirectory.GraphClient.ConnectionWrapper.DownloadData(Uri address, WebHeaderCollection additionalHeaders)
       at Microsoft.Azure.ActiveDirectory.GraphClient.GraphConnection.GetCore(Type objectType, String objectId, FilterGenerator filterGenerator, Uri& requestUri)
       at Microsoft.Azure.ActiveDirectory.GraphClient.GraphConnection.Get(Type objectType, String objectId, LinkProperty expandProperty)
       at Microsoft.Azure.ActiveDirectory.GraphClient.GraphConnection.Get(Type objectType, String objectId)
       at Microsoft.Azure.ActiveDirectory.GraphClient.GraphConnection.Get[T](String objectId)
       at Readify.Sudo.Web.Infrastructure.Identity.GraphClaimsAuthenticationManager.Authenticate(String resourceName, ClaimsPrincipal incomingPrincipal) in
       at System.IdentityModel.Services.WSFederationAuthenticationModule.SignInWithResponseMessage(HttpRequestBase request)
       at System.IdentityModel.Services.WSFederationAuthenticationModule.OnAuthenticateRequest(Object sender, EventArgs args)

Tuesday, August 25, 2015

SharePoint : Access Denied when crawling mysites

Error Message: Access is denied. Verify that either the Default Content Access Account has access to this repository, or add a crawl rule to crawl this repository. If the repository being crawled is a SharePoint repository, verify that the account you are using has "Full Read" permissions on the SharePoint Web Application being crawled.

Solution 1: Add backconnection host names in the registry

under HKLM\SYSTEM\CurrentControlSet\Control\Lsa\MSV1_0
Add a Multi-String Value with name "BackConnectionHostNames".
Add the host names for the sites that are on the local server.

Solution 2: Disable loop-back check on the server  ( or add host name to

Under "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa"
Create a new 32bit DWORD value "DisableLoopbackCheck" with value as 1

Solution 3: Give your content access account "Retrieve People Data for Search Crawlers" permission on the user profile service application.

Solution 3 : Verify that the search content access account has full read permissions on the web-application. 

SharePoint 2013 web application authentication fails

Error: SharePoint 2013 web application authentication fails, prompts for credentials 3 times and displays blank page.

Kernel Mode Authentication is not supported in SharePoint Products. I would suggest turning this off. If you want this enabled, there is a workaround s - 

Change the ApplicationHost.config file to have the bit
<windowsauthentication enabled="true" useapppoolcredentials="true">< /windowsauthentication>

Saturday, August 22, 2015

Tips for writing or enhancing formal documents : From my personal observations

Tips for writing or enhancing formal documents : From my personal observations.

Certain words are used more commonly in speaking where the body language of the speaker assists in conveying the real intention of the words usage. A tip would be write as you normally would and check for such common words and see if it is the right word for the sentence.

I have pointed out a few examples below. 

Good: Check if the word good accurately describe the situation that you are trying to convey. It is common to use the term good, but it might not have the accuracy in conveying the message. E.g. with good training you might have meant that the training was intensive of fast paced or effective or thorough, however the reader will not get the same meaning. 

Small: Similar to the word good above.

Also:  Is a word used a lot in certain demography while speaking. Check if this word is really necessary in the sentence. 

The:  Is a word used a lot in certain demography while speaking. Check if this word is really necessary in the sentence.

Helping / assisting: e.g. I received some assistance in the work. Here since the writer was the one who was involved in the work, he/she knows the type of assistance received however the reader could take it in either way.  You could have received assistance in terms of guidance or effort. By guidance I mean how to do the work. By effort I mean since there was lot of work you received another helping hand and you probably even provided guidance to the helper in getting the task completed.

The same: Used a lot in India instead of "the (item, etc.) described above"


Some of the words are more due to usage differences in different cultures. E.g. The term company a lot in India instead of employer which is a more common and accepted usage in Australia.  

This is also evident sometimes in the way some ideas are written. Some cultures are not used to writing in a definitive way. One example is “I hope this experience gave me an insight into…” whereas the intention was to convey “This experience gave me an insight into…” the former sometimes written in a way of saying that I have the knowledge in a modest way. It is advised to be definitive in terms of what you are conveying. A yes, no or don’t know. 

Feel free to add your comments in case you have observed similar words or phrases and I can add to the list.

Friday, August 21, 2015

SharePoint : Failed to load dependency assembly

A windows update broke search in SharePoint.

We could not resolve the error in the server. We have to recreate search service in a new server.
You are luck if your search topology has redundancy.

Errors in ULS:

AssemblyReflector : Failed to load dependency assembly in load context and in load from context. Assembly: BihConsumerInterop System.IO.FileNotFoundException: Unable to find the specified file.

Errors in Process Monitor

HKU\S-1-5-21-494056553-2953882651-1462924595-7389\Software\Microsoft\.NETFramework NAME NOT FOUND
HKU\S-1-5-21-494056553-2953882651-1462924595-7718_Classes\CLSID\{BDEADF26-C265-11D0-BCED-00A0C90AB50F}\InprocServer32 NAME NOT FOUND

HKLM\SOFTWARE\Microsoft\.NETFramework\JitLockWrite NAME NOT FOUND

SharePoint 2013 : Error while accessing MySite after changing MySite URL

Error while accessing MySite after changing MySite URL.

Solution :
Verify permissions on mysite service application for the account used to change the URL.
Re enable the service connection to the webapplication.

ULS Error:

Exception occurred loading user profile (/default.aspx): Microsoft.Office.Server.UserProfiles.UserProfileApplicationNotAvailableException: UserProfileApplicationNotAvailableException_Logging :: UserProfileApplicationProxy.GetRawPartitionID has null proxy  
 at Microsoft.Office.Server.Administration.UserProfileApplicationProxy.GetRawPartitionID(SPServiceContext serviceContext)  
 at Microsoft.SharePoint.Portal.WebControls.ProfilePropertyLoader.get_CurrentPartitionId()  
 at Microsoft.SharePoint.Portal.WebControls.ProfilePropertyLoader.OnInit(EventArgs e).

Friday, August 14, 2015

SharePoint : Workflow stuck at a stage, on a list with unique permissions

In SharePoint 2013, workflow runs with the users permissions unless it has an app step with elevated permissions. If your list has unique permissions, ensure that your workflow history list and task list have write permissions for the user.

Another item to check for are steps in the workflow where the user do not have permissions to do. One instance is if the user has no delete access on the list but there is a step in the workflow to delete an item in the list.  This was not an issue in SharePoint 2010 as the workflow was running as system account.

Also, do not make your workflow to depend on or read the last modified date on the item. Because the workflow will change it.

Thursday, August 6, 2015

SharePoint 2013 : Access Denied while attempting to restore site collection

$webApp = Get-SPWebApplication -identity "webapplicationURL"

Thursday, July 23, 2015

SharePoint 2013 Connection string location in Registry

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\15.0\Secure\ConfigDB

Key : dsn

Friday, July 17, 2015

SharePoint online - Update timezone for a sitecollection via CSOM

Here is a snippet to update timezone for a site-collection via CSOM

            Web web = clientContext.Web;
            RegionalSettings webRegionalSettings = web.RegionalSettings;
            Microsoft.SharePoint.Client.TimeZone currentTimeZone = webRegionalSettings.TimeZone;

            //Get the current site TimeZone  
            ConsoleLogger.LogMessage(LogLevel.Verbose, "Current TimeZone: " + currentTimeZone.Id + " - " + currentTimeZone.Description);

            //Get web timezones
            TimeZoneCollection webTimeZones = webRegionalSettings.TimeZones;

            // 76 (UTC+10:00) Canberra, Melbourne, Sydney
            Microsoft.SharePoint.Client.TimeZone newTimeZone = webTimeZones.GetById(76);
            webRegionalSettings.TimeZone = newTimeZone;

Additionally, adding a loop gives me a list of all the SharePoint online timezones
            foreach (Microsoft.SharePoint.Client.TimeZone timezone in webTimeZones)
                ConsoleLogger.LogMessage(LogLevel.Verbose, String.Format("Id : {0} , Description : {1} ", timezone.Id, timezone.Description));


The output looks like :
Id : 39 , Description : (UTC-12:00) International Date Line West
Id : 95 , Description : (UTC-11:00) Coordinated Universal Time-11
Id : 15 , Description : (UTC-10:00) Hawaii
Id : 14 , Description : (UTC-09:00) Alaska
Id : 78 , Description : (UTC-08:00) Baja California
Id : 13 , Description : (UTC-08:00) Pacific Time (US and Canada)
Id : 38 , Description : (UTC-07:00) Arizona
Id : 77 , Description : (UTC-07:00) Chihuahua, La Paz, Mazatlan
Id : 12 , Description : (UTC-07:00) Mountain Time (US and Canada)
Id : 55 , Description : (UTC-06:00) Central America
Id : 11 , Description : (UTC-06:00) Central Time (US and Canada)
Id : 37 , Description : (UTC-06:00) Guadalajara, Mexico City, Monterrey
Id : 36 , Description : (UTC-06:00) Saskatchewan
Id : 35 , Description : (UTC-05:00) Bogota, Lima, Quito
Id : 10 , Description : (UTC-05:00) Eastern Time (US and Canada)
Id : 34 , Description : (UTC-05:00) Indiana (East)
Id : 88 , Description : (UTC-04:30) Caracas
Id : 91 , Description : (UTC-04:00) Asuncion
Id : 9 , Description : (UTC-04:00) Atlantic Time (Canada)
Id : 81 , Description : (UTC-04:00) Cuiaba
Id : 33 , Description : (UTC-04:00) Georgetown, La Paz, Manaus, San Juan
Id : 65 , Description : (UTC-04:00) Santiago
Id : 28 , Description : (UTC-03:30) Newfoundland
Id : 8 , Description : (UTC-03:00) Brasilia
Id : 85 , Description : (UTC-03:00) Buenos Aires
Id : 32 , Description : (UTC-03:00) Cayenne, Fortaleza
Id : 60 , Description : (UTC-03:00) Greenland
Id : 90 , Description : (UTC-03:00) Montevideo
Id : 103 , Description : (UTC-03:00) Salvador
Id : 96 , Description : (UTC-02:00) Coordinated Universal Time-02
Id : 30 , Description : (UTC-02:00) Mid-Atlantic
Id : 29 , Description : (UTC-01:00) Azores
Id : 53 , Description : (UTC-01:00) Cabo Verde
Id : 86 , Description : (UTC) Casablanca
Id : 93 , Description : (UTC) Coordinated Universal Time
Id : 2 , Description : (UTC) Dublin, Edinburgh, Lisbon, London
Id : 31 , Description : (UTC) Monrovia, Reykjavik
Id : 4 , Description : (UTC+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna
Id : 6 , Description : (UTC+01:00) Belgrade, Bratislava, Budapest, Ljubljana, Prague
Id : 3 , Description : (UTC+01:00) Brussels, Copenhagen, Madrid, Paris
Id : 57 , Description : (UTC+01:00) Sarajevo, Skopje, Warsaw, Zagreb
Id : 69 , Description : (UTC+01:00) West Central Africa
Id : 83 , Description : (UTC+01:00) Windhoek
Id : 79 , Description : (UTC+02:00) Amman
Id : 5 , Description : (UTC+02:00) Athens, Bucharest, Istanbul
Id : 80 , Description : (UTC+02:00) Beirut
Id : 49 , Description : (UTC+02:00) Cairo
Id : 98 , Description : (UTC+02:00) Damascus
Id : 50 , Description : (UTC+02:00) Harare, Pretoria
Id : 59 , Description : (UTC+02:00) Helsinki, Kyiv, Riga, Sofia, Tallinn, Vilnius
Id : 101 , Description : (UTC+02:00) Istanbul
Id : 27 , Description : (UTC+02:00) Jerusalem
Id : 7 , Description : (UTC+02:00) Minsk (old)
Id : 104 , Description : (UTC+02:00) E. Europe
Id : 100 , Description : (UTC+02:00) Kaliningrad (RTZ 1)
Id : 26 , Description : (UTC+03:00) Baghdad
Id : 74 , Description : (UTC+03:00) Kuwait, Riyadh
Id : 109 , Description : (UTC+03:00) Minsk
Id : 51 , Description : (UTC+03:00) Moscow, St. Petersburg, Volgograd (RTZ 2)
Id : 56 , Description : (UTC+03:00) Nairobi
Id : 25 , Description : (UTC+03:30) Tehran
Id : 24 , Description : (UTC+04:00) Abu Dhabi, Muscat
Id : 54 , Description : (UTC+04:00) Baku
Id : 106 , Description : (UTC+04:00) Izhevsk, Samara (RTZ 3)
Id : 89 , Description : (UTC+04:00) Port Louis
Id : 82 , Description : (UTC+04:00) Tbilisi
Id : 84 , Description : (UTC+04:00) Yerevan
Id : 48 , Description : (UTC+04:30) Kabul
Id : 58 , Description : (UTC+05:00) Ekaterinburg (RTZ 4)
Id : 87 , Description : (UTC+05:00) Islamabad, Karachi
Id : 47 , Description : (UTC+05:00) Tashkent
Id : 23 , Description : (UTC+05:30) Chennai, Kolkata, Mumbai, New Delhi
Id : 66 , Description : (UTC+05:30) Sri Jayawardenepura
Id : 62 , Description : (UTC+05:45) Kathmandu
Id : 71 , Description : (UTC+06:00) Astana
Id : 102 , Description : (UTC+06:00) Dhaka
Id : 46 , Description : (UTC+06:00) Novosibirsk (RTZ 5)
Id : 61 , Description : (UTC+06:30) Yangon (Rangoon)
Id : 22 , Description : (UTC+07:00) Bangkok, Hanoi, Jakarta
Id : 64 , Description : (UTC+07:00) Krasnoyarsk (RTZ 6)
Id : 45 , Description : (UTC+08:00) Beijing, Chongqing, Hong Kong, Urumqi
Id : 63 , Description : (UTC+08:00) Irkutsk (RTZ 7)
Id : 21 , Description : (UTC+08:00) Kuala Lumpur, Singapore
Id : 73 , Description : (UTC+08:00) Perth
Id : 75 , Description : (UTC+08:00) Taipei
Id : 94 , Description : (UTC+08:00) Ulaanbaatar
Id : 20 , Description : (UTC+09:00) Osaka, Sapporo, Tokyo
Id : 72 , Description : (UTC+09:00) Seoul
Id : 70 , Description : (UTC+09:00) Yakutsk (RTZ 8)
Id : 19 , Description : (UTC+09:30) Adelaide
Id : 44 , Description : (UTC+09:30) Darwin
Id : 18 , Description : (UTC+10:00) Brisbane
Id : 76 , Description : (UTC+10:00) Canberra, Melbourne, Sydney
Id : 43 , Description : (UTC+10:00) Guam, Port Moresby
Id : 42 , Description : (UTC+10:00) Hobart
Id : 99 , Description : (UTC+10:00) Magadan
Id : 68 , Description : (UTC+10:00) Vladivostok, Magadan (RTZ 9)
Id : 107 , Description : (UTC+11:00) Chokurdakh (RTZ 10)
Id : 41 , Description : (UTC+11:00) Solomon Is., New Caledonia
Id : 108 , Description : (UTC+12:00) Anadyr, Petropavlovsk-Kamchatsky (RTZ 11)
Id : 17 , Description : (UTC+12:00) Auckland, Wellington
Id : 97 , Description : (UTC+12:00) Coordinated Universal Time+12
Id : 40 , Description : (UTC+12:00) Fiji
Id : 92 , Description : (UTC+12:00) Petropavlovsk-Kamchatsky - Old
Id : 67 , Description : (UTC+13:00) Nuku'alofa
Id : 16 , Description : (UTC+13:00) Samoa

Sunday, July 12, 2015

SharePoint 2013 : Unique edit permissions not working

An error message "Server unable to process the request" is displayed when a user with unique permissions on a list tries to update a list item.

This issue sometimes occurs in a Site Collection, however the exact error is unknown.

A workaround is to create a permission level on the site collection which consists of the following:

  • User remote interfaces (Use SOAP, Web DAV, or SharePoint Designer 2010 interfaces to access the Web site)
  • Open(Open a Web site, list, or folder to access items inside that container).
Assign this new permission level at site collection and site level to the users requiring unique permissions.

The users will now be able to edit the list items.

Monday, June 15, 2015

Strange IE Mailto link error - Sys.InvalidOperationException

I am getting a strange error in IE. There is an A tag with a mailto link. It works fine for one email ID but fails for multiple email IDs.
End user uses IE 9 with Win 7 SP1
Tested in IE 11 with Win 7 SP1 too.

This happens only in their environment. The site is an Office 365 SharePoint site. Can see that the link instead of just opening the email client does a post back and has this error message :

Sys.InvalidOperationException: Cannot access

Has anyone come across this error?

Profiler log goes like this :

Anonymous function
Anonymous function
Anonymous function
Anonymous function

Sunday, June 14, 2015

Evaluating SharePoint requirements

SharePoint is a productivity tool for information management and discovery. Any requirement that does not tie back to this rule has to be re-evaluated.

This is my personal opinion.

A few more of my quotes.

Never hide anything from your doctor, lawyer or SharePoint consultant. It will cost you your health, wealth, or both.

What happens in SharePoint stays in SharePoint.

Friday, April 24, 2015

Unable to mount windows 10 technical preview ISO

Problem : Unable to Mount windows 10 ISO

Solution: execute this command from an elevated command prompt. Now you should be able to mount the ISO.

fsutil sparse setflag "File_Name" 0

fsutil sparse setflag "Windows10_TechnicalPreview_x64_EN-US_10041.iso" 0

I was trying to mount the downloaded copy of windows 10 technical preview and it was giving error.
Finally the above command saved me.

Reference :

Key :  Problem mounting ISO on Hyper-v
Issue mounting ISO downloaded from technet / internet

Thursday, March 26, 2015

Sharepoint web services root stopped

Some of you might have noticed during troubleshoot that the SharePoint web services root is in a stopped state. This is quite normal. The error is usually somewhere else.

Friday, March 6, 2015

SharePoint 2013 - .master file not generated from masterpage html

Created a master page from seattle.html and uploaded it via a Sandbox solution. But the master page file .master was not generated automatically.

Saved the file manually and the .master file was generated.

Tried updating the file with powershell, still masterpage .master file not generated.

Noticed the following properties and the value was set to true for a successful conversion.

<mso:htmldesignconversionsucceeded msdt:dt="string">False</mso:htmldesignconversionsucceeded>

<mso:htmldesignstatusandpreview msdt:dt="string"></mso:htmldesignstatusandpreview>

used powershell to set the value to false and updated the file. The .master file was generated successfully.

Wrote a small powershell snippet as part of deployment to ensure that .master is generated before setting the masterpage.

word-wrap:break-word does not work

During troubleshooting a css where the text wrap was just not working even though the style had word-wrap:break-word included.

Later figured that there was another css property which was preventing it from working.

Added this to style and it started working.

white-space: normal;

Install active directory module for powershell

From an elevated powershell, run the following.

Import-Module ServerManager
Add-WindowsFeature RSAT-AD-PowerShell

Restart is not required.

To import the module, use :

Import-Module ActiveDirectory  

Javascript Debugging - javascript function executed twice

I had an issue with a javascript function being called twice on document ready.
Finally figured that I had included the script at two locations. Best way to figure this out is to simply search in page view source to see if the file is included twice.

Thursday, February 5, 2015

Google Authenticator - Invalid pin

If you are facing invalid pin while trying to login to a two factor authenticated site with Google Authenticator, the question is did you travel outside your timezone? :)

In the Authenticator app there is a setting for time correction. You can sync time with the server and everything should be good again.