Thursday, November 19, 2015

How to get site relative URL through PowerShell, for SPWeb?

It's easy to get server relative URL through "ServerRelativeUrl" property, for SPWeb. But how to get the site relative URL?

Below is how I get it.

$SPSiteServerRelativeUrl = $site.ServerRelativeUrl
$SPWebServerRelativeUrl = $web.ServerRelativeUrl
$SPWebSiteRelativeUrl = ""
if ($web.IsRootWeb -eq $false)
$SPWebSiteRelativeUrl = $SPWebServerRelativeUrl.Replace($SPSiteServerRelativeUrl + "/", "")
Write-Host "SPWebSiteRelativeUrl=$SPWebSiteRelativeUrl" -f DarkYellow

Monday, October 26, 2015

PowerShell color variable

I'd like to standardize the colors in my PowerShell script outputs.  So I need something like "WarningColor", "ErrorColor", "DebuggingColor", etc.

It turns out quite easy.  Below is an example.

$DebuggingColor = [System.ConsoleColor]::DarkGreen
$HighlightColor = [System.ConsoleColor]::Green
$WarningColor = [System.ConsoleColor]::Yellow
$ErrorColor = [System.ConsoleColor]::Red

Write-Host "hello world" -f $DebuggingColor


Saturday, September 26, 2015

Every politician should learn SharePoint

We all heard the sad news from Mecca. When I see the picture below, I realized that there was something wrong.

Some people said that every one should learn to code, I don't agree about that. But, maybe, every politician should learn SharePoint.

Anyone who is familiar with SharePoint knows that we should not put all data into one site collection. Instead, we split the data into different category, and then create an dedicated and isolated site collection for each of the category.

If we split those 2 million people into 1000 groups, and then set 20 meter gap among those groups, would similar stampede ever happen?

100,000 police deployed there didn't help much. It's like, no matter how many CPU cores, how much RAM and how many SSD are there, for a SharePoint farm with even 2000 users, if we put all data into one site collection, sooner or later, we will see the sad ending.

Thursday, August 27, 2015

SharePoint 2016 is good!

After two days of playing on it, I like it!

New and improved features are listed here.  In general, it's like the upgrading from Windows XP to Windows 7.  The main functionalities and UI are same, but got improved everywhere.

My main concerns are:

1. How's the "Add-ins" model get improved?

2. What's going to replace InfoPath?

3. Any AI (Artificial intelligence) in it?

4. Can we put a service (such as "Microsoft SharePoint Foundation Web Application" and "User Profile Synchronization Service") into a Container?

Hopefully we can figure that out in the next six months.

Some screenshots here.

SharePoint Designer 2016 CTP is not released yet, but version 2013 seems still support it, althought the version number is not recognized correctly.

Wednesday, August 26, 2015

App / Add-in model is dead?

Andrew Connell just released an interesting post, which mentioned:

"Customers already dismiss the add-in model... I don't see many people using it today. There's a lot of talk around it, but in reality, I bet Microsoft wouldn't want to admit how many people have built add-ins and deploy them to SharePoint Online in Office 365. Another model would be dismissed even quicker."

App / Add-in model is quite complicated at this stage. The development/troubleshooting productivity is poor. However, the idea is correct: we should keep development outside of SharePoint server.

No doubt, add-in mode on SharePoint 2016 will be much better. Then, more and more developers will start to utilize it. However, I do concern about the latency issue. Response from another (potentially quite far away remote) server, is always much slower than response from another process on the same server. What can we do to resolve this problem? Well infrastructure design and AJAX asynchronous calls help a lot, but no doubt, it could be headache.

So far, I haven't jumped to "App / Add-in model", because, no need. What I did, is to minimize the requirement of full trust solutions.

Sometimes we need to explain to clients that internal SharePoint sites don't need to look like internet facing sites; sometimes we need to use "windows task scheduler + PowerShell script" to replace timer job; sometimes we need "Content Editor Web Part + javascript + css" to replace web parts; etc.

Four years ago, 100% of the sites I created used full trust solutions; now, 5%

The whole farm is stable, the clients are happy, IT department colleagues are happy, and I am happy!

Wednesday, July 29, 2015

How to remove Document ID after disabling "Document ID Service" feature?

After disabling "Document ID Service" site collection feature, the field "Document ID" is still in the "Display Form". That's annoying.

However, it's easy to remove/hide it, with the help from the famous freeware "SharePoint Manager".

Go to the library, then expand "Fields", then change the property "Sealed" from True to False, click "Save"; then change the property "ShowInDisplayForm" from True to False, then click "Save" again.


PS: we cannot do the same change with this field in list content type or site content type.

Monday, July 13, 2015

The feature we really need in SharePoint (but may not get it in the next 30 years)

Recently I uploaded all my photos and videos to “Google Photos”, and realized that Google recognized all metadata and keywords of each photo and video automatically.

That resolved the most painful issue of photo management.

Then I realized that this is the critical feature we need in SharePoint.

When millions of files are stored in SharePoint, it's almost impossible to ask thousands of users to attach "tags" manually to documents. And, when the content of a file is changed, sometimes we also need to update the relevant metadata.

However, it's easy to understand that's much more complex than attaching tags to photos and videos. AI needs to understand the documents, to some extent.

Let's wait for SharePoint 2040.


PS: If this is technically impossible, I hope SharePoint can offer some "possible tags" when a document is uploaded. That should not be too hard.