Thursday, October 27, 2016

Making a Link to a Document in SharePoint 2013 Open in client program

When we go to a Document Library list view, we can open the document in client program directly if:

1. In the library settings, the default open behavior is "open in the client application"

2. In Central Admin -> Manage web application -> General Settings -> Browser File Handling -> Permissive

However, if we want to add the document link to a page, then user may get prompt message from IE as below, when clicking that link:

That means the document will be downloaded to local hard drive first, then be opened from there.

What if we want to open the document in the SharePoint library directly?

If "Office Web Apps" ("Office Online Server") is available, we can follow this link to open the document in web browser. Or else, we need the help of JavaScript. Insert a Content Editor Web Part to that page, then add the script below to it.  Done!

" rel="sp_DialogLinkNavigate">Document Link Label

Friday, October 14, 2016

The smart watch everyone needs

There are many different types of smart watch on the market. The question is, do we really need them? Do they really change our life style? How many people need to record their heart beat / blood pressure / location all the time? Do we enjoy playing games on "watch"? Do we really want to use "smart watch" to replace "smart phone"? All current smart watches are developed in wrong direction. Watch is very small, but most vendors want to copy the features from smart phone to it! It's like what Microsoft did before: replicate Windows OS to smart phone. This attempt is doomed to fail from the very beginning. From my point of view, a smart watch everyone needs is a simple one with the features below. No fancy appearance, and it is not going to compete with smart phone. 1. Identity verification. I don't want to carry keys, security passes, membership cards, discount cards, library card, drive license, credit cards, transportation card, cash, etc. And, I even don't need to carry mobile phone everywhere. Smart watch is a perfect device for identity verification: light, handy, not likely to left on car / office / home / hotel, or get stolen. Work with fingerprint scanning, it's also much more secure against hacker's attack. At checkout desk of supermarket, no need to take credit card / cash / smart phone out of pocket any more, just raise your hand, put your finger on the watch, "Beep", done. Do we still need wallet? I doubt it. 2. Receive “Check Code” How many passwords do we need to memorize? How complicated each one need to protect you to resist attacks? With the help of this watch, all online system can turn into "passwordless". Want to log on email system? Please enter your email address, then click "submit" button, wait for a few seconds later, enter the "Check Code" just received on watch, then click "submit" again, done. 3. Receive notification For any important action online, such as payment, no matter it's through credit card or PayPal, or just getting the salary of last week, we can get notification in almost real time.
The same notification can also be sent to specified email account.
So, if anything goes wrong, we can respond in short time. 4. Long lasting battery We don't need to keep the watch running all the time. It should be "wake up" instantly when making payment, and then go to sleep again. So, we may only need to run it for a few minutes a day, which means, it can last for months in one charge! When the battery needs recharge, we will get notification. 5. Remote control / No keyboard. We should not be able to enter any text on the watch. So, all configuration is done through computer or smart phone remotely. That's one of the major differences between Watch and Phone. 6. Tough No dust, no water, no shock, and works well in extreme temperature. 7. Enclosed environment This watch is critical to user's daily life, so, security gets highest priority. To minimize risk, it should not allow any third-party software. 8. Date / Clock Only provide basic information. 9. GPS and Emergency report No map needed, but it's nice to know that you can always get help, anywhere, anytime. 10. Privacy OK, this is the inevitable drawback of this watch. But, as it doesn't collect information more than current mobiles, I assume it's fine. How much I am happy to pay for this kind of watch? $200 is fine. But, I think, Google may be happy to give people for free, as exchange of their personal information.

Wednesday, October 5, 2016

Without backup/restore, how to change managed path of a site collection?

Based on the answer from Microsoft, backup/restore is the only way to change site collection managed path.

"backup/restore" actually copy the whole site collection to a file, then re-import it into SharePoint farm. This approach works well. But, instead of external file, we can also use a temporary database to hold the site collection data. Comparing to "backup/restore", it's much faster.

Below is the PowerShell script.

Mount-SPContentDatabase -AssignNewDatabaseId -Name SP_Content_Tmp -DatabaseServer $DatabaseServer -WebApplication $WebAppUrl

Copy-SPSite -Identity $SiteUrlSource -DestinationDatabase SP_Content_Tmp -TargetUrl $SiteUrlDest

Remove-SPSite -Identity $SiteUrlSource -confirm:$false

Get-SPTimerJob -WebApplication $WebAppUrl job-site-deletion | Start-SPTimerJob

Move-SPSite -Identity $SiteUrlDest -DestinationDatabase $ContentDatabase -Confirm:$false

Get-SPTimerJob -WebApplication $WebAppUrl job-site-deletion | Start-SPTimerJob

Dismount-SPContentDatabase -Identity SP_Content_Tmp -Confirm:$false

[update, 2016-10-19]

Windows Form program to generate PowerShell script:

Tuesday, October 4, 2016

Copy-SPSite and 404 error


"Copy-SPSite" is a new command available from SharePoint 2013. In theory, we can generate a identical site collection with different Site ID and URL.

However, when trying to open the new site from web browser, I got "404" Page Not Found error. I am not the only one who got this problem.

[Error Message]

Error message in web page:

This error (HTTP 404 Not Found) means that Internet Explorer was able to connect to the website, but the page you wanted was not found. It’s possible that the webpage is temporarily unavailable. Alternatively, the website might have changed or removed the webpage.

Error message in ULS:

Exception trying get context compatibility level: System.NullReferenceException: Object reference not set to an instance of an object.  
 at Microsoft.SharePoint.SPSite.PreinitializeServer(SPRequest request)  
 at Microsoft.SharePoint.SPSite.GetSPRequest()  
 at Microsoft.SharePoint.SPSite.InitSite()  
 at Microsoft.SharePoint.ApplicationRuntime.SPRequestModule.GetContextCompatibilityLevel(Uri requestUri)

[Trouble Shooting]

Initially, I thought I just need to specify a new content database for the new site, but, that didn't help.

Not sure what went wrong. I guess there is a bug in the command implementation.

Cumulative Updates (until CU201609) haven't mentioned this issue.

Do we have to switch back to "Backup-SPSite and Restore-SPSite"? The real problem is, SharePoint doesn't allow duplicated SiteID in a farm.


Luckily, I found a way to make it work. Below is the script. Hopefully it can save you some time.

Mount-SPContentDatabase -AssignNewDatabaseId -Name $databaseNameTmp -DatabaseServer $databaseServer -WebApplication http://$webAppSource$envSuffix/

Copy-SPSite http://$webAppSource$envSuffix/sites/$siteNameSource -DestinationDatabase $databaseNameTmp -TargetUrl http://$webAppSource$envSuffix/sites/$siteNameDest

Move-SPSite http://$webAppSource$envSuffix/sites/$siteNameDest -DestinationDatabase $databaseNameSource -Confirm:$false

Dismount-SPContentDatabase -Identity $databaseNameTmp -Confirm:$false

The script above generate a new site in the same web application.  To copy site to different web application is similar.

Mount-SPContentDatabase -AssignNewDatabaseId -Name $databaseNameTmp -DatabaseServer $databaseServer -WebApplication http://$webAppSource$envSuffix/

Copy-SPSite http://$webAppSource$envSuffix/sites/$siteNameSource -DestinationDatabase $databaseNameTmp -TargetUrl http://$webAppSource$envSuffix/sites/$siteNameDest

Move-SPSite http://$webAppSource$envSuffix/sites/$siteNameDest -DestinationDatabase $databaseNameSource -Confirm:$false

Dismount-SPContentDatabase -Identity $databaseNameTmp -Confirm:$false

Mount-SPContentDatabase -AssignNewDatabaseId -Name $databaseNameTmp -DatabaseServer $databaseServer -WebApplication http://$webAppDest$envSuffix/

Move-SPSite http://$webAppDest$envSuffix/sites/$siteNameDest -DestinationDatabase $databaseNameDest -Confirm:$false

Dismount-SPContentDatabase -Identity $databaseNameTmp -Confirm:$false

Friday, September 30, 2016

SharePoint 2016 Data Access Performance test

Four years ago, I did a simple data access performance test on SharePoint 2010 ( ). Today, same test was done on SharePoint 2016.

Test environment is similar. Host machine is Ivy bridge core i7 + Samsung 840 Pro SSD + 32GB RAM, and the SharePoint 2016 virtual server is with 4 CPU cores and 12GB RAM. Most of the SP services (including Search service) are disabled. SQL Server is 2016 DEV CU2 with maximum 4GB RAM on the same virtual machine. During test, only 6GB RAM is consumed on SP server.

The test result is a bit disappointing. The only improvement is "bulk update", and others are much slower.

Plan to do a similar test on SharePoint Online in the near future, through PowerShell + CSOM. Hopefully it's more interesting.

To make it easier for comparison, SharePoint 2010 test result is copied as below.

SharePoint 2010.

ActionSingle, 1 threadBulk, 1 threadSingle, 4 threadBulk, 4 thread

Here is SharePoint 2016.

ActionSingle, 1 threadBulk, 1 threadSingle, 4 threadBulk, 4 thread
Single, 1 thread

Bulk, 1 thread

Single, 4 thread

Bulk, 4 thread

[update, 2016-10-19]

Windows Form program:

Wednesday, September 21, 2016

Office 365 portal is awkward, confusing and daunting

It's really designed by and for developers. :-)

How many users are there happy to spend time to get familiar with these 18 icons, to figure out which one they should click, and then start to work there?

What users want to do here?

1. Create / modify a document (OneDrive, SharePoint, Video, Word, Excel, PowerPoint, OneNote, Sway)
2. Talk / contact some one. (Mail, People, Groups. Where's Lync?)
3. Figure out what need to do. (Mail, Calendar, Planner, Tasks, Delve)
4. Web surfing. (Yammer, Newsfeed, Delve)

If users could only see 4 entry icons here, I believe that they would feel much more comfortable.

But, it's still a bit messy.

SharePoint is the place to store information. Are emails information? How about People contact details? Calendar events? Tasks? Why so much information is stored in other separate places?

If we could store all information in SharePoint, then many of those services could be moved into SharePoint User Profile module, such as Mail, People, Groups, Calendar, Planner, Tasks, Yammer, Newsfeed. (OneDrive and Delve are already there)

We even don't need Microsoft Graph anymore! That's a big relief to developers, as they only need to learn how to access SharePoint data.

Do you like this idea?  Any comments are welcome!

[update, 2016-09-29]

If a document needs to be shared in SPO, Yammer, Planner and Groups, does that mean that the same document has 4 separate copies?

To manage the versions and permissions of this document must be hard.  :-)

Friday, June 17, 2016

SharePoint 2016 CU installation failure: "Exception: The upgraded database schema doesn't match the TargetSchema"

After installing CU 201606 for SharePoint 2016, "SharePoint 2016 Products Configuration Wizard" threw out error:

Database is in compatibility range and upgrade is recommended

In ULS log doesn't help much, and Windows Event Viewer tell us:

Failed to upgrade SharePoint Products.
An exception of type Microsoft.SharePoint.PostSetupConfiguration.PostSetupConfigurationTaskException was thrown.  Additional exception information: The upgrade command is invalid or a failure has been encountered.
Failed to upgrade SharePoint Products.
Microsoft.SharePoint.PostSetupConfiguration.PostSetupConfigurationTaskException: Exception of type 'Microsoft.SharePoint.PostSetupConfiguration.PostSetupConfigurationTaskException' was thrown.
   at Microsoft.SharePoint.PostSetupConfiguration.UpgradeTask.Run()
   at Microsoft.SharePoint.PostSetupConfiguration.TaskThread.ExecuteTask()

So I went to Central Admin, and then clicked "Upgrade and Migration" page:

It brings us here:


We can see that the content database "SP_Content_team80_tmp" caused the problem.

It's easy to solve the problem. Just run the PowerShell script below:

Upgrade-SPContentDatabase SP_Content_team80_tmp -NoB2BSiteUpgrade -Confirm:$false

Then, re-run "SharePoint 2016 Products Configuration Wizard".


Hope this trick save you some time   :-)

[update, 2016-08-17]

One line of PS script to upgrade all content databases.

Get-SPContentDatabase | ?{$_.NeedsUpgrade –eq $true} | Upgrade-SPContentDatabase -Confirm:$false