Switch between modern SharePoint homepages using PnP PowerShell

I’ve been working on a modern intranet project amongst over projects for the last 12-months. This has been more about the transformation of content and business processes, rethinking information architecture and reimagining a modern intranet than it has been about custom development.

We’ve recently been testing variations in the design of a homepage with different audiences. This side-by-side comparison has allowed end-user feedback, performance and accessibility testing. The same approach has also been useful for previewing and testing the capabilities of new features (like the new Yammer web part). The challenge comes when you need to promote or switch over one of these variations as the new site homepage. The homepage is the page users are directed to when first navigating to a site or clicking on the site logo. It is like as important as the index.html or default.aspx page existence to a website. Note that these variations of the homepage permit testing of content and not site configuration. To test navigation, theme or similar we have separate sites and environments for this purpose.

To solve the problem switching the homepage from an existing page whilst preserving the home.aspx page name I’ve leveraged the SharePoint Pnp cmdlets to create a script that will rename or remove the current homepage (and can remove it through a toggle) and then rename an existing page to make it the new homepage.

Set-SPNewHomePage script demonstration
Demonstration of the Set-SPNewHomePage script in action.

Use my PnP PowerShell script to replace the home.aspx page

Alternative methods

Change the default homepage through SharePoint

Site Owners can use the out-of-the-box make homepage action to make any page the default homepage or welcome page. This is available from the toolbar in the site pages library. But this keeps the page name and means the default page is /sitepages/randompagename.aspx instead of the standard /sitepages/home.aspx that all sites have. From my perspective this is not great. Certainly, intranet-like sites should follow some basic content management principles. Call in a touch on the OCD side but consistently having a standard homepage is one of these for me.

Screenshot of setting a new homepage in the site pages library.
Screenshot of setting a new homepage in the site pages library.

Change the welcome page site property through Site Settings or PowerShell

Previously you could use the classic settings page (typically exposed by the publishing feature) or by browsing to /_layouts/15/AreaWelcomePage.aspx to make changes to the welcome page. This method no longer works and throws an error.

As with the make homepage action describe earlier this changes the default homepage to the use the page name you have provided and means the site won’t be available if users have bookmarked the site with the page name (/sitepages/home.aspx) in the URL.

Screenshot of the welcome page site settings page.
Screenshot of the welcome page site settings page.

What is my point? To this day can I still memory recall core settings pages. With these, you can quickly review or makes changes to settings pages rather than using the UI to navigate to them. This includes those that may no longer be exposed in the UI. Whilst my memory serves me well I don’t recommend this approach as these pages and settings are gradually being replaced with alternatives or removed by the SharePoint and Office 365 engineering team for a reason.

Instead, you can also use Pnp PowerShell to change the site welcome page property. I’ve provided an example script below.

As simple as my script is, it is the approach worth learning the most. I hope you find this article useful and as with all Pnp development effort. Sharing is caring!

#MSIgnite sessions available in a single spreadsheet

Update (31/01/15): Session spreadsheet updated and now includes 275 sessions.

Those involved with SharePoint, Office 365, Yammer, the communities and the wider industry will already know about the Ignite conference Microsoft has planned for May this year. Microsoft published the conference sessions on the Ignite website this afternoon, introduced through this Office Blog post.

The Office Blog post included a video from Julia White in which she shared what to expect from the conference. She also said in the video “without giving away too much, be the first to see a lot of new technology”, hinting that we will probably see the next versions of SharePoint and Exchange etc. The SharePoint Twitter account also shared the tweet below, with another video (#InBillWeTrust) confirming the next version of SharePoint (SharePoint 2016) will be shared during the conference.

The conference is just around the corner. At the time of writing this post, there are 272 sessions published on the website and I’m sure this will increase in the coming weeks and months. Over a year ago, I created a PowerShell script to help myself and others easily review all the sessions that were planned for the then SharePoint Conference (#SPC14).

You’ll be pleased to know I’ve done something similar again this year, although this year I’ve quickly gone about it using jQuery. I plan to create and share a bookmarklet but until then I’ve shared the first Ignite sessions spreadsheet for your viewing. The latest version of the sessions spreadsheet and jQuery bookmarklet are shared below.

MSIgnite Sessions Spreadsheet

Javascript via JSFiddle

Fingers crossed I can attend #MSIgnite and have the opportunity to meet the great people I met at #SPC14 again!

What types of email does SharePoint send automatically?

Update: After reviewing the SMTP logs, on a very active SharePoint 2013 environment and some further research, I now have an extensive list of the types of emails SharePoint sends. Most of these now include an example image of the email that is sent.

I recently responded to a question posted to Twitter using the #SPHelp hashtag. Tim Ferro was trying to understand all the different types of email that SharePoint sends automatically.

While I may have misunderstood his tweet to begin with, it certainly got me thinking about what emails does SharePoint actually send. I gave it some thought with a colleague and have produced this post as a result.

  1. MySite Cleanup Notification
  2. Task assigned to you notification
  3. Alerts
  4. Storage limit exceeded
  5. Sharing – Invited to
  6. Site Mailbox Created
  7. MySite Setup Notification
  8. Mentioned in a conversation
  9. Site Deletion Notice (Site Policy)
  10. Site Access Requests

Example of SharePoint Emails

There is very little information that provides an answer to Tim’s question. I’ve attempted to create a consolidated view of all the different types of emails that SharePoint sends. I have sourced example images from various sources on the internet. They have been credited to the author and include a link to the originating content.

MySite cleanup notification

MySite Cleanup Notification. Credit: SharePoint 2013 Admin blog http://sharepoint2013admin.wordpress.com/2013/11/19/my-site-cleanup-timer-job-2/
MySite Cleanup Notification. Credit: SharePoint 2013 Admin blog http://sharepoint2013admin.wordpress.com/2013/11/19/my-site-cleanup-timer-job-2/

Task assigned to you notification

Task assigned to you email. Credit: Tomislav Tasic http://tomislavspadmin.blogspot.co.uk/2014/06/enable-email-notifications-for-tasks.html
Task assigned to you email. Credit: Tomislav Tasic http://tomislavspadmin.blogspot.co.uk/2014/06/enable-email-notifications-for-tasks.html

Alerts

SharePoint Alerts. Credit: Merin Nakarmi http://sharepointrealm.blogspot.co.uk/2013/06/how-to-cusomize-alert-email-for.html
SharePoint Alerts. Credit: Merin Nakarmi http://sharepointrealm.blogspot.co.uk/2013/06/how-to-cusomize-alert-email-for.html

Storage Limit Exceeded

Storage Quota Exceeded. Credit: Three Will https://www.threewill.com/2013/12/storage-quotas-in-sharepoint-online/
Storage Limit Exceeded. Credit: Three Will https://www.threewill.com/2013/12/storage-quotas-in-sharepoint-online/

Sharing – Invited to …

Mentioned in a conversation email. Credit: Jennifer Mason, CMS Wire http://www.cmswire.com/cms/social-business/sharepoint-2013-social-features-highlights-019624.php?pageNum=2
Mentioned in a conversation email. Credit: Jennifer Mason, CMS Wire http://www.cmswire.com/cms/social-business/sharepoint-2013-social-features-highlights-019624.php?pageNum=2

Site Mailbox Created

Site Mailbox Created. Credit: Mark Kashman http://blogs.office.com/2013/04/02/whats-new-in-sharepoint-online-top-10/
Site Mailbox Created. Credit: Mark Kashman http://blogs.office.com/2013/04/02/whats-new-in-sharepoint-online-top-10/

MySite Setup Notification

MySite Setup. Credit: Sudhit Kesharwani http://sharepoint.stackexchange.com/questions/72530/sharepoint-mysite-changing-the-notification-email
MySite Setup. Credit: Sudhit Kesharwani http://sharepoint.stackexchange.com/questions/72530/sharepoint-mysite-changing-the-notification-email

Mentioned in a conversation

Mentioned in a conversation
Mentioned in a conversation email. Credit: Jennifer Mason, CMS Wire http://www.cmswire.com/cms/social-business/sharepoint-2013-social-features-highlights-019624.php

Site Deletion Notice (Site Policy)

Site Deletion Notice. Steven Boyle, SharePoint IT Pro Blog http://blogs.technet.com/b/tothesharepoint/archive/2013/03/28/site-policy-in-sharepoint.aspx
Site Deletion Notice. Steven Boyle, SharePoint IT Pro Blog http://blogs.technet.com/b/tothesharepoint/archive/2013/03/28/site-policy-in-sharepoint.aspx

Site Access Requests

Site Access Requests. Jasper Oosterveld https://www.nothingbutsharepoint.com/sites/eusp/Pages/SharePoint-Online-2013-Request-Access-Procedure.aspx
Site Access Requests. Jasper Oosterveld https://www.nothingbutsharepoint.com/sites/eusp/Pages/SharePoint-Online-2013-Request-Access-Procedure.aspx

Other possibilities

There are a number of other emails that SharePoint might send, which I have been unable to confirm at this time.

  • Health Analyser – Alerts
  • Managed Metadata Service – term managed and term submission
  • Solution resource usage – site collection exceeded daily resource usage
  • Membership requests (requests to join/leave groups)
  • MySite new followers and Colleague and keyword suggestions
  • Site Collection Upgrade Notification (2010 > 2013)
  • Created and Delete Upgrade Evaluation Site Collections
  • Removal notifications of user provisioned Site Collections
  • Search Service Application
  • Apps Service Application
  • eDiscovery
  • Record
  • Publishing
  • Retention

Community Contribution

Not stopping there, I have also asked the community via the Office 365 Technical Network on Yammer (10,000+ members). Let’s see what people come back with. In time I’d like to add more detailed summaries of these including a sample of the emails.

Event Receiver to Remove “Recent” from SP2013 Quick Launch

I’m sure removing the Recent heading from the Quick Launch in SharePoint 2013 has been talked about a million times over since SharePoint 2013 was launched. It’s been solved in this way and that way, by hand, with javascript and programmatically. In this post, I share the code to remove the heading with the ListAdded event receiver.

With and without the Recent heading on the Quick Launch navigation.
With and without the Recent heading on the Quick Launch navigation.

Event receiver code

It’s based on code provided as an answered on the SharePoint StackExchange website by Remko van Laarhoven. I’ve then wrapped in a list added event receiver so that it is executed each time a new list or library is added. As the list/library is then not available on the Quick Launch I’ve added a couple of lines to then show it.

Update (22nd June 2014): since creating this solution I have since discovered that the Recent heading still is created even with the event receiver triggering when lists/libraries created from templates. I resolved this by adding a sleep before the code to remove the heading is executed.
[code language="c"]
System.Threading.Thread.Sleep(1500);
This in conjunction with the jQuery method prevent users from ever seeing the Recent Heading whether they are viewing the page or editing the links on the page.
[code language="js"]
// Hide Recent on Quick Launch
$("#ctl00_PlaceHolderLeftNavBar_QuickLaunchNavigationManager .ms-core-listMenu-root li:contains('Recent')").children().remove();
$("#ctl00_PlaceHolderLeftNavBar_QuickLaunchNavigationManager .ms-core-listMenu-item:contains('Recent')").remove();
[code language="c"]
public class ListAddedEventReceiver : SPListEventReceiver
{
public override void ListAdded(SPListEventProperties properties)
{
base.ListAdded(properties);
SPWeb web = properties.Web;
if (web != null)
{
//Sleep
System.Threading.Thread.Sleep(1500);

//Remove heading
var title = SPUtility.GetLocalizedString("$Resources:core,category_Recent", null, web.Language);
SPNavigationNodeCollection nodes = web.Navigation.QuickLaunch;
foreach (SPNavigationNode node in nodes)
{
if (node.Title.ToLower().Equals(title.ToLower()))
{
// Delete the recent heading node
node.Delete();
break;
}
}
// Show list on the quick launch
SPList list = web.Lists[properties.ListId];
list.OnQuickLaunch = true;
list.Update();
}
}
}

Download Remove Recent Heading Solution

For those who don’t want to create the event receiver themselves in Visual Studio or don’t know how to, I have a packaged the solution so that you can deploy the WSP to your environment. For those who don’t know how to use this code, I will write a post explaining how to create this event receiver using Visual Studio from an IT Pros perspective very soon.

jcallaghan.removerecentheading.wsp

As with anything you download from the internet remember to review, rename and test this code/solution before using it in a production environment.