Mar 22

Registering a SharePoint Online Hub Site

SharePoint Online Hub sites were announced at Ignite 2017. They are getting rolled out to Targeted Release Tenants during the week of March 21 2018. As of today, the UI elements (setup and navigation, for example) aren’t there yet, but we can start testing and experimenting with some other elements like news rollups and theming. This article will describe how to get it working.

NOTE: I am working in a demo tenant with Targeted Release available to all users.

Prerequisites

  • Install the SharePoint Management Shell – 64-bit version. If you have an older version installed, you’ll need to uninstall and re-install. (Please Microsoft fix this.) The version I ended up with is 16.0.7414.1200.
    • I am using Visual Studio Code, but you can use the SPO Management Shell directly.
  • I’m guessing you need to be in the SharePoint Administrator role at least. My tests were done using the Global Admin accounts.

Create Hub Site and one or more Associated Sites

The first thing you’ll want to do is either identify a hub site or create a new one. It doesn’t matter if it’s a Team or a Communication site; both should work. Then create another site that will become associated to the hub site. My hub is an HR Portal Communication site, and the associated site is the HR Benefits Team site. The URLs are, respectively:

https://tenant.sharepoint.com/sites/HR-Portal
https://tenant.sharepoint.com/sites/HR-Benefits

As the screenshots below show, I also added two news posts to the Portal site, and a single news post to the Benefits site.

PowerShell Steps

Launch your PowerShell environment. I use a line to grab my admin credential and then I connect to the tenant’s admin site.

$admin = Get-Credential -UserName "admin@tenant.onmicrosoft.com"
Connect-SPOService -url https://tenant-admin.sharepoint.com -Credential $admin

From here, it’s easy to register your hub site and add associated sites to it:

Register-SPOHubSite https://tenant.sharepoint.com/sites/HR-Portal

You should end up with something like this:

ID : 12a0026a-c8a5-4d5d-b7af-66b3b01849bd
Title : HR Portal
SiteId : 12a0026a-c8a5-4d5d-b7af-66b3b01849bd
SiteUrl : https://tenant.sharepoint.com/sites/HR-Portal
LogoUrl :
Description :
Permissions :

Refreshing the HR-Portal site didn’t result in any visible changes.

Now, back in PowerShell, add the HR Benefits site as an associated site to the hub site:

Add-SPOHubSiteAssociation https://tenant.sharepoint.com/sites/HR-Benefits -HubSite https://tenant.sharepoint.com/sites/HR-Portal
There aren’t any messages to let us know anything happened.
Refreshing the Benefits site shows the new theme from the hub:

In my earlier tests, my news post from an associated site rolled up to the hub site!

This is a fresh test from earlier today. It’s been a bit over an hour since I’ve run the scripts this time and the news hasn’t rolled up yet. I had also changed the hub theme to ensure it gets pushed down to the associated sites. I still don’t see it reflected yet, but I will update this post when that does happen.

I may play around with the only other cmdlet I found which is Unregister-SPOHubSite.

UPDATE: News Rollup

After a SharePoint Hub Site AMA, one of the comments suggested that I have to add the News web part again. Sure enough, once that happened, the news rolled up from the Benefits site.

April 2 2018 Update

In my test today, the Team site that I had created on March 28 (but only registered as a hub site today) rolled up the news posts from my two associated sites without my having to add the News web part.

UPDATE: Theme Refresh

I did un-register the hub site, set a new theme, and then re-register to for a theme change for the associated site. I don’t think we have to do this if we do change themes at the hub, but this is something to keep an eye on.

April 2 2018 Update

I created a new hub and associated two sites to it. I then change the theme on the hub. The two associated sites eventually had their themes refreshed to match the hub. The delay was different on the two associated sites, with the second site getting the theme refresh within about 15 minutes or so.

UPDATE: Hub Navigation

April 2 2018 – The navigation elements are now lighting up immediately as soon as I register the hub site. Still waiting to see my two associate sites automatically added to the hub navigation. After about 30 minutes, I only see a link to the hub site itself.


Hope this helps; happy publishing!

Mar 02

Deleting SharePoint Online Team Site

I’ve been working with SharePoint for so long that I’ll sometimes miss things that are right in front of my eyes.

We perform a lot of tests, so creating and deleting sites is almost an everyday occurrence. With SharePoint Online, the two types of ‘modern’ sites right now (March 2018) are Team Sites and Communication Sites.

After my testing, I deleted my Communication Site using the normal method: Settings | Site Information | View all site settings – and there it is: “Delete this site”.

“Delete this site”, under “Site Actions”. (Background is blue due to selected theme.)

All good and in my world of ‘normal’.

I wanted to do the same for my Team Site:

Hmm…. no “Delete this site”!

In my hasty I-know-what-I’m-doing clicking, I completely glossed over the obvious, that works for both sites in the modern world; stop at “Site Information” for a minute and see:

“Delete site” is right here!

The other way, for Team Sites only that have the associated Outlook Group available to it (i.e., Exchange Online has been provisioned), is go to Group Settings and find the link there:

Group Settings…

Deleting the Group will delete all associated assets, including the Team Site.

Sep 22

Copying a set of Folders via Powershell and Robocopy

I wanted to move some files from one location to another. All of the folders started with a set prefix. For example, “Backup One”, “Backup Two”, “Backup 2011-09”, etc. I wanted to use Robocopy because of it’s “restartable” mode. I’m still quite new to Powershell so I figure I better blog this one as I’m sure I’ll need it, or something similar, again.

In my sample below, “ParentFolder” is the parent folder (duh) of the “Backup” folders above. Therefore, we have something like this:

D:\ParentFolder\Backup One
D:\ParentFolder\Backup Two
D:\ParentFolder\Backup 2011-09

The command:

Get-ChildItem D:\ParentFolder -Filter "Backup*" -Name | ForEach-Object { robocopy "D:\ParentFolder\$_" "X:\$_" /Z /S /MOVE }
  • -Filter parameter only returns those items that start with “Backup”. This will probably return files too. I didn’t have them, so it wasn’t a problem, but I should probably figure that out too.
  • -Name parameter only shows the folder name, nothing else.
  • Iterate over each item returned and perform the robocopy command, moving all the files and subfolders to X:.

After the command runs, you should end up with, along with all of the files within, of course:

X:\Backup One
X:\Backup Two
X:\Backup 2011-09

Aug 24

Deleting a SharePoint List using Powershell

When I’m doing development tasks, there are times I need to quickly create and delete SharePoint content. Lists are one of those. Documenting a few different ways to delete a SharePoint 2010 list using Powershell.

Two lines:

$w = Get-SPWeb "http://sps2010"
$w.Lists.Delete([System.Guid]$w.Lists["My Custom List"].ID)

One line:

Get-SPWeb "http://sps2010" | Where-Object { $_.Lists.Delete([System.Guid]$_.Lists["My Custom List"].ID) }

or

Get-SPWeb "http://sps2010" | % { $_.Lists.Delete([System.Guid]$_.Lists["My Custom List"].ID) }

Jan 26

Event Receivers

Two excellent resources for ramping up on SharePoint 2007 event receivers.

Jan 14

IIS7 Application Pool Reset

In IIS6 on Windows Server 2003, we could recyle the application pool that hosted our SharePoint site in order to force the web application to perform a JIT compile. This would then reload any DLLs it required. This saved a considerable amount of time over an IISRESET.

That command is:

C:\windows\system32\IISApp.vbs /a "SP Site App Pool" /r

(Note that the first time you run IISAPP.vbs, you’ll get a few confirmation prompts.)

This VBS script does not exist in IIS7 on Windows Server 2008, but the good news is there is an even better command:

c:\windows\system32\inetsrv\AppCmd Recycle AppPool "SP Site App Pool"

Type “AppCmd /?” for a list of all the useful actions you might want perform against your IIS7 installation.

Nov 01

SPC09 Recap

Better late than never…

It’s about time I wrote about the experiences of what was the SharePoint Conference, 2009 edition, in Las Vegas. By now many others have had their recap, and with my own experiences being somewhat similar, I shall try to keep mine succint, but entertaining.

My first major Microsoft conference was the Office/SharePoint conference in Redmond (or was it Bellevue) in March 2005. I had just started with Habañero Consulting Group, had just gone through a nasty learning experience on a custom “workflow” type issues and tasks solutions on SharePoint 2003 (which was NOT fun for many reasons), and so was pretty wide-eyed and overwhelmed when I attended the sessions. Aside from the two co-workers I went with, I knew no one else, didn’t know any of the “big names”, and didn’t really have any sort of game-plan whatsoever. We heard a lot of ideas, I saw some code, saw some bad presentations, and concluded the conference with pretty much a “meh”. The most exciting part was the road trip from Vancouver in my car, and I’ll never forget the “thud” that my car had to endure as I drove it off a curb because my “navigator” (she will remain nameless, for now…) missed the exit, it was dark, and I was desperate to turn around and find the hotel.

SharePoint Conference 2008 came to Seattle in February, if i recall correctly. Due to the success the product had in 2007, it was going to be a big deal for SharePoint 2007, with which I’d been working since the summer of 2006 (Beta 2). Having spent two years prior on MCMS 2002, I was fortunate to be involved in a WCM solution in the summer of 2007. By then, I had learned a lot through discovery, but also through reading the content of others. I also attended the first running of Andrew Connell‘s WCM401 online class. I had a bit of a game plan this time, but it mostly involved the sessions, attending them as strategically as I could, trying to learn things outside of my SharePoint comfort zone. I learned some new things, saw better presentations, but generally didn’t feel as out of place as I did in 2005. I attended SharePint, met a few people throughout the conference, but pretty much stayed with my co-workers and didn’t realize the social aspect of these conferences. Since the two MOSS exams were available for free, I decided to give them a shot and passed both. Cool. The stay at the W was also a nice luxury that Habanero generously provided.

Throughout 2007 and 2008, I was focussed primarily on SharePoint projects. I learned more and more with each one (as one should), became more confident, and looked forward to the next conference. Soon after it was announced, I bought an early-bird ticket. Throughout 2009, I grasped on to Twitter, started following a few SharePoint people, and once in a while would engage in some sort of “conversation” with people whom I’ve never met. It was very cool. Heading down to Las Vegas for SPC09 I decided I would try to meet as many people as I could, to personally thank them for the work they have put into the community over the last few years from whom I’ve benefitted directly as well. I decided to splurge a bit and stayed at THEhotel, attended SharePint at EyeCandy, and throughout the conference just shook hands and tried to track down a few people to say “hi” and “thanks”. I had never been to Vegas before, but it wasn’t until Tuesday evening (after the 80s party with Huey Lewis and the News) that I even stepped outside of the Mandalay Bay Center.

It was a great conference with a lot of content (overload), but what made it really special for me was the chance to meet many of the cool people in the SharePoint community of which I’m proud to be part of.

Oct 17

SharePoint Conference 2009

Well, like about 7000 other people from around the world, I’ll be at the SharePoint Conference in Las Vegas this coming week. I’m excited about it and looking forward to meeting many new people. I’ll also be looking to thank some great community contributors to whom I am very grateful and appreciative.

I’ll be leaving Vancouver mid-morning on Sunday, arriving by about 1:30 or so. Hope to see you there!

I'll be at SPC09

I'll be at SPC09

Sep 30

New Blog

Finally selected a web host for my new domain, installed WordPress, upgraded it to 2.8.4, and installed a new theme (custom one under development).

Wasn’t so bad, quite nice and easy actually. Next up, moving my old blog postings over to here. Any posts with a date earlier than this one are posts the old blog (which explains why this “New Blog” post appears “in the middle”).

Jun 16

Registering a CSS File in SharePoint

I have a custom publishing site definition. It was, of course, based off the default publishing site definition. I re-organized some features around, and added custom versions of required features just so I could control everything a little more to my liking. Anytime we do this, however, we run the risk of “what did I break?” syndrome.

One of my clients was using the Content Editor Web Part on one of her page layouts (instead of using a RichHtmlField – long story). She noted that she could not select the “Use Predefined Table Format” in the Table Editor web dialog. Hmmm… I didn’t do anything specific to disable that capability, so I needed to do some digging.

Since I was using a custom publishing site definition, I needed to determine if this behaviour was happening with the default Publishing Portal definition. Sure enough, adding a CEWP to the home page of the Publishing Portal yielded the same effect: I could not use the predefined table formats. I then check the Press Releases default page, which does have a RichHtmlField for me to play with. I can use the predefined formats here. I proceeded to add a CEWP to the zone at the bottom of the page, and here I can also use the predefined formats. Interesting…

I fired up my favourite search engine, and came across this posting from Microsoft: How to enable the “Use Predefined Table Format” setting when you use a Windows SharePoint Services template in SharePoint Server 2007. Cool! But note the location of the CSS: /_LAYOUTS/1033/STYLES/HtmlEditorTableFormats.css. In my case, I have the French language pack installed, which means I have to account for the 1036 LCID also.

I checked the master pages and page layouts that PublishingLayouts feature use, and note that there is not a reference to that CSS. Nor is it in the page layouts found in the PublishingResources feature. What gives? What’s the correct syntax?

No matter. I’ll just add a link to the CSS by building out the path to the right LCID folder, using something like System.Threading.Thread.CurrentThread.CurrentUICulture to get the LCID. After some frustrations (which I won’t get into here), I quickly realized that this would not work in my scenario (Canadian English is not 1033) either.

I looked at the source code for my out-of-the-box publishing portal (the Press Releases page). I noticed that core.css also comes from the LAYOUTS/1033/Styles folder. Some more digging, and I realized that I did not need to specify the full path, like this example taken from BlueBand.master:

<SharePoint:CssRegistration name="<% $SPUrl:~sitecollection/Style Library/~language/Core Styles/controls.css %>" runat="server"/>

but instead I needed simply this:

<SharePoint:CssRegistration name="HtmlEditorTableFormats.css" runat="server" />

and SharePoint takes care of the rest, building out the path to the appropriate Styles as required, like this:  

<link rel="stylesheet" type="text/css" href="/_layouts/1033/styles/Htmleditortableformats.css?rev=guYGdUBUxQit03E2jhSdvA" />

Here is a great post which talks about what’s going on, and what renders HtmlEditorTableFormats links. It explains why I could not find it in any of the master pages or page layouts: the RichHtmlField web control inserts CSS links to HtmlEditorTableFormats.css and HtmlEditorCustomStyles.css OnLoad() . <groan! />