SharePoint 2016

SPFx - the first steps

posted by Benny Skogberg   [ updated ]

Starting with SharePoint Framework can be a daunting task. Especially since one may be new to TypeScript, Node, Gulp and Yeoman which are preferred parts of the framework. In essence SPFx can be a great step for other developers to start working with SharePoint, since you don't need a local SharePoint environment. The only thing you need is a developer tenant of Office 365, which comes for free for up to a year. You could develop locally as well, but I find it easier to work with the developer tenant directly since you have a real Office 365 instance already in place and don't need to use (and produce) Mockup data.

But lets leave the tools for a minute. Just accept the fact that they work, and that you have used scaffolding with Yeoman ‘yo @microsoft/sharepoint’ and started your HelloWorld project with ‘gulp serve’. That’s all we need for now. If not, head over to the source HelloWorld WebPart, and come back here when your done. 

So now you have your HelloWorld webpart running both locally and on your development tenant. But if we want to add another property in the property pane? That's quite simple, since everything (so far) is in the same .ts file. First, at the top add the PropertyPaneCheckbox in the import clause of @microsoft/sp-client-preview. When done, we can add the checkbox in our webpart property. I added three just for fun so my group now looks like this:

              groupFields: [
                PropertyPaneTextField('description', {
                  label: strings.DescriptionFieldLabel
                PropertyPaneCheckbox('valid', {
                  text: 'Valid'
                PropertyPaneCheckbox('governed', {
                  text: 'Managed by IT'
                PropertyPaneCheckbox('hr', {
                  text: 'Only visible for HR'

And here comes the cool part. When I save my .ts file - gulp (which is still running) makes funny noises (OK, no sound provided in PowerShell which I use) with verbose messages. It recompliles your webpart according to your request.

Reloading the webpart at my development tenant, I see the webpart change instantly. I don't even have to delete it and add it again (like old times). Everything just works Now. Suddenly, programming is fun again when you don't have to wait for hooking up to your environment. I just works, and my previous changes is still there. 

SPFx new webpart properties

An exception of type Microsoft.SharePoint.Administration.SPUpdatedConcurrencyException was thrown

posted Nov 23, 2015, 12:34 AM by Benny Skogberg   [ updated Aug 20, 2016, 6:55 AM ]

When you run the command PSConfig.exe -cmd upgrade -inplace b2b -wait and get an error, you often solve it by running Get-SPProduct -local to ensure that the the server is in sync.

The error message you get is

11/23/2015 08:34:40  1  ERR          Failed to upgrade SharePoint Products.
An exception of type Microsoft.SharePoint.Administration.SPUpdatedConcurrencyException was thrown.  Additional exception information: An update conflict has occurred, and you must re-try this action. The object SPUpgradeSession Name=Upgrade-20151123-083423-444 was updated by DOMAIN\SP_Farm, in the PSCONFIG (5092) process, on machine SERVER.  View the tracing log for more information about the conflict.
Microsoft.SharePoint.Administration.SPUpdatedConcurrencyException: An update conflict has occurred, and you must re-try this action. The object SPUpgradeSession Name=Upgrade-20151123-083423-444 was updated by DOMAIN\SP_Farm, in the PSCONFIG (5092) process, on machine SERVER.  View the tracing log for more information about the conflict.
   at Microsoft.SharePoint.Administration.SPConfigurationDatabase.StoreObject(SPPersistedObject obj, Boolean storeClassIfNecessary, Boolean ensure)
   at Microsoft.SharePoint.Administration.SPPersistedObject.BaseUpdate()
   at Microsoft.SharePoint.Upgrade.SPUpgradeSession.Update()
   at Microsoft.SharePoint.Upgrade.SPUpgradeSession.ContinueOnLocalThread(Guid id, Boolean consoleOutput)
   at Microsoft.SharePoint.PostSetupConfiguration.UpgradeTask.Run()
   at Microsoft.SharePoint.PostSetupConfiguration.TaskThread.ExecuteTask()

You may get stuck in a position where you still can't upgrade. Then you have to expand your PSConfig command into this:

PSConfig.exe -cmd upgrade -inplace b2b -wait -force -cmd applicationcontent -install -cmd installfeatures -cmd secureresources

This command solved the error in my 6-tier farm with 2 WFE, 2 APP and 2 SQL Servers mirrored and belonging to AlwaysOn Availability Group. As a side note - I have to remove the UsageAndHealth-DB from the availability group before upgrading SharePoint.

Find the FIM Client path

posted Nov 16, 2015, 6:10 AM by Benny Skogberg

If you have the two FIM services running (Forefront Identity Manager Service & Forefront Identity Manager Synchronization Service) you can start the Forefront Identity Manager 2010, which you use to manage synchronization i detail. The path to the FIM Client is:

C:\Program Files\Microsoft Office Servers\15.0\Synchronization Service\UIShell\miisclient.exe

FIM Client 2010

There is a compatibility range mismatch between the Web server and database "WSS_Content"

posted Sep 9, 2015, 11:41 PM by Benny Skogberg   [ updated Sep 11, 2015, 1:28 AM ]

This an annoying error message which can happen in various scenarios. I got this one trying to assign a SPWeb object. I knew the SPWeb existed since it was the root site collection. The complete error message was:

There is a compatibility range mismatch between the Web server and database "WSS_Content", and connections to the data have been blocked to due to this incompatibility. This can happen when a content database has not been upgraded to be within the compatibility range of the Web server, or if the database has been upgraded to a higher level than the web server. The Web server and the database must be upgraded to the same version and build level to return to compatibility range.

Searching the web get many answers, but none that linked to the source. There isn’t any reference (yet) on SharePoint 2013, but it works just as well for 2013 as well. The command-line you run is

PSConfig.exe -cmd upgrade -inplace b2b -wait

Script Output

Running the GUI-version of “SharePoint 2013 Products Configuration Wizard” doesn’t help, so you really need to run the script using SharePoint 2013 Management Shell as administrator. But you need to do so with your SP_Install or SP_Farm account which shouldn’t be local administrator on the machine. To overcome this problem temporarily add SP_Install or SP_Farm as local administrator and proceed with the script. You may need to run the script several times, as the script does a lot of magic on your content database. I needed four times to make it work all the way without warnings. All four upgrade sequences need to be successful before you’re done.

The -cmd is a mandatory parameter where you specify which action you want to perform. Here we’re using the upgrade command to fix our error of compatibility mismatch.

With the –inplace parameter we specify whether to use version to version upgrade or build to build. This can be quite confusing since when we look at our Configuration database version in the Servers in Farm page in Central administration (<CentralAdminURL:Port>/_admin/FarmServers.aspx) and it specifies a build number on SharePoint Foundation 2013 only. Every time you install a Cumulative Update (CU) or Public Update (PU) you need to run PSConfig. Most of the blogs use b2b parameter value, because you are patching the server, not changing version (i.e. SharePoint 2010 to SharePoint 2013). So we’re using the b2b parameter value in this scenario. See SharePoint Build Number vs Version? for more information.

Using –wait parameter is important to use since it specifies that SP Management Shell doesn’t return until the upgrade process is completed. And we want to wait and see that our failing content database is really upgraded.

There may be things to do after the upgrade i successful. Please check out the log:

Successful result script output

Reference: PSConfig command-linereference (SharePoint Server 2010)

WARNING: The user hasn't logged on to mailbox Discovery Search Mailbox

posted Sep 2, 2015, 12:03 PM by Benny Skogberg   [ updated Sep 3, 2015, 12:27 PM ]

When we want to know the total storage of all the mailboxes we have in Office 365, we are encouraged to use PowerShell and Exchange Online cmdlets. Before we get to the state where we can run scripts against our Exchange Online we have used the scripts to do so.

#Connect to Office 365
$credential = Get-Credential
Import-Module MSOnline
Connect-MsolService -Credential $credential

#Connect to Exchange Online
$exchangeSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://outlook.office365.com/powershell-liveid/" -Credential $credential -Authentication "Basic" –AllowRedirection

Import-PSSession $exchangeSession -DisableNameChecking

And we run the script against the mailbox – just to be informed that it doesn't work as expected.

Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | Select DisplayName, StorageLimitStatus, TotalItemSize, TotalDeletedItemSize, ItemCount, DeletedItemCount | Export-CSV "C:\Temp\Mailboxes.csv" –NoTypeInformation

The output is something like this:

WARNING: The user hasn't logged on to mailbox 'DiscoverySearchMailbox{D919BA05-46A6-415f-80AD-7E09334BB852}'('d907f6dc-f370-4e48-b1e6-28eaa0375409'), so there is no data to return. After the user logs on, this warning will no longer appear.

So you struggle and try to sign in to the Discovery Search Mailbox. I even tried to create rules in mine, just to nudge it a bit and maybe something would happen?! But I have an Office 365 Business Essential subscription, and needs an Exchange Online plan 2 to create rules – so back to square one.

Instead of this – we need to filter out the Discovery Search Mailbox when getting the real mailbox data. Instead of using the above script, you can use the following which also provides a warning in the end – but the benefit is that you get the data in your csv-file.

$mailboxes = Get-Mailbox -ResultSize Unlimited

foreach ($mailbox in $mailboxes)
     if($mailbox.DisplayName -ne "Discovery Search Mailbox")
         Write-Host $mailbox.DisplayName
         $mailbox | Get-MailboxStatistics | Select DisplayName, StorageLimitStatus, TotalItemSize, TotalDeletedItemSize, ItemCount, DeletedItemCount | Export-CSV "C:\Temp\Mailboxes.csv" –NoTypeInformation –Append

And you have the result to open up in MS Excel and modify to your liking.

Service Connection – Configure Service Application Associations by adding a member to a custom group of connections in SharePoint Server 2010.

posted Sep 2, 2015, 12:00 PM by Benny Skogberg

If you have an existing named proxy group of Service Connections, where you want to add members (new connections to new services in a service farm), you need to fire up PowerShell to add new members (connections). At first we need to know the name of the service application proxy group. This is done by a fairly simple PS-command.

Get-SPServiceApplicationProxyGroup | select Name

Next you copy the name of the Service Application Group that you want to add a new member to, and replace the <SA Group Name> with the real name.

$sapg = Get-SPServiceApplicationProxyGroup | Where-Object {$_.Name -eq "<SA Group Name>"}

Now you have a reference to the custom group, and need to get the proxy you want to add as a new member.

Get-SPServiceApplicationProxy | select DisplayName, Id

Copy the Id of the ServiceApplicationProxy you want to add and use it as the -Identity parameter

$sap = Get-SPServiceApplicationProxy -Identity 53f7b267-de00-4b7d-a12c-0fb505e94669

Finally add your Proxy to the Proxy Group

Add-SPServiceApplicationProxyGroupMember -Identity $sapg -Member $sap

Check the Web Application Service Connection, and verify that you have successfully added the new member

PowerShell Online

posted Sep 2, 2015, 11:44 AM by Benny Skogberg

Yes, it's possible, but not as extensive as you're familiar on a SharePoint Server. Still, it's useful and as simple as on a SharePoint Sevrer installation. Before you begin - download the SharePoint Online Management Shell​. (I use Windows 8, and didn't need the ​Windows Management Framework 3.0. But if your installation fails, try this installing the WMF 3.0 first)​.

When installed, fire upp the SharePoint Online Management Shell and connect to your SharePoint Online Site using the Connect-SPOService​ cmdlet.​
> ​Connect-SPOService -Url https://contoso-admin.sharepoint.com -credential admin@contoso.com

Hit enter, and you'll get a Login window to add your password. It's possible to login without the password request window if you type your Connect-SPOService script differently (shown in example 2 of the above link to the cmdlet). However, I save my scripts all the time, and don't want my password to the online site to be un-encrypted. So I type the password every time in the windows password text input field:

Typing the correct password, and you're in. Type Get-SPOSite and see what you got. :)

Saving the script to a .ps1 file, other familiar problems arise. You may need to set execution policy to run the script, and you must run the SharePoint Online Management Shell as administrator, to be able to change execution policy. Right-clicking I saw my other tool available... the PowerShell ISE. So I tried that one instead. If you have the PS ISE installed, no need to download SharePoint Online Management Shell either. Just connect, after you set the execution policy :)

That's it. Now browse through the available cmdlets at ​​Index of Windows PowerShell for SharePoint Online cmdlets​ and see what you can do.​

Happy Scripting!

Manage DNS and rename site

posted Sep 2, 2015, 3:58 AM by Benny Skogberg

​I was under the impression that one could link several domains to one SharePoint Online environment. This is not the case. You have to choose which domain you want to use at any given time. You can't have both.

I tried to have both http://WebArchitect.se and http://SharePointOnline.se pointing to the same public web site. It can't be done, since you need to rename your public site collection to your domain name. I don't think I can use Alternative Access Mapping (AAM) either. So far I havn't layed my eyes on it.

Rename the site

Switching between verified domains is easy. Just select the checkbox next to your public URL, and click on the "Website Domain" button. This opens a modal dialog titled "Rename Your Website" (I'd really like to meet the User Experience Team on this labeling clash). Still on the Rename Your Website modal dialog, select the URL you want your public domain to have. Save, and wait for your current site to be deleted (the name that is). Reload your site collection page, and you see your newly created DNS record.

UnGhosting Customized Page Layouts with PowerShell

posted Aug 31, 2015, 3:10 AM by Benny Skogberg

Sometimes you end up in a solution where someone have been kind enough to use SharePoint Designer to edit a Page Layout. This means that you are not able to change the Page Layout through your deployed code, in a package. Changes made in the development environment doesn’t show up in production. Your Page Layout is in a Ghosted mode of its origin, and we need to Un-Ghost the Page Layout to be able to change it from a package created in our development environment.

Thus you use this script to first find out which Page Layouts have been changed, and uncomment the Revert Content Stream to actually change the Page Layout back to an UnGhosted mode.

$s = Get-SPSite https://siteCollectionUrl

$w = $s.RootWeb

$ps = New-Object Microsoft.SharePoint.Publishing.PublishingSite($s)

$pls = $ps.PageLayouts


foreach ($pl in $pls)


    $f $w.GetFile($pl.ServerRelativeUrl)

    if ($f.CustomizedPageStatus -eq "Customized")



        Write-Host "Layout page name: " -NoNewline

        Write-Host $f.Name        

        Write-Host "Status before: " -NoNewline

        Write-Host $f.CustomizedPageStatus




        Write-Host "Status after: " -NoNewline

        Write-Host $f.CustomizedPageStatus






SharePoint 2010: Migrate Users to new Active Directory Environment

posted Aug 31, 2015, 3:09 AM by Benny Skogberg

When switching from one AD-environment to another, you sometimes end up with users who don't get imported correct. You see them when they don't have first name and last name when they are logged in to SharePoint. They have <domain>\<username> visible instead.

But let's start from the beginning and migrate the users with the following command:

STSADM –o migrateuser –oldlogin OLDDOMAIN\user1 –newlogin
    NEWDOMAIN\user1 –ignoresidhistory

After that you need to run a full user profile synchronization. When this is done, continue and see which users where not imported correct.

# Clean up accounts that is not imported correctly

$upsa = Get-SPServiceApplication | Where-Object {$_.TypeName -like
    "User Profile Service Application"}

# List all user accounts that is not imported correctly
Set-SPProfileServiceApplication $upsa -GetNonImportedObjects $true

# Remove user accounts not imported correctly 
# Uncomment line below to run
Set-SPProfileServiceApplication $upsa -PurgeNonImportedObjects $true

# Run a full User Profile Service Syncronisation, and make sure users
# end up in Profile database.
# If not, users who log in will create new NonImportedObject accounts

This might have to be repeated several times, especially if you're in a live environment where users login during the day. Eventually these orphan user profiles will disappear.
If you have a lot of users, the script will take a lot of time - so please be patient unless you get an error from PowerShell.
Good Luck!

1-10 of 16