Blog

  • Security trimmed top navigation links

    Security trimmed top navigation links

    I was asked to review a client environment yesterday to find out why the links in their top navigation bar were displaying for users that did not have permission to the particular sites.

    Creating sites

    It turns out that when sites were being created by the client on SharePoint Foundation 2010 they were being created without the ‘include on the top navigation bar’ check box ticked. As a result, the link was then not automatically added to the top navigation bar but instead later manually added and so was not security trimmed link.

    Display this site on the top link bar of the parent site
    Display this site on the top link bar of the parent site

    It was then after removing permissions to the various sites that it became clear that users were able to see the top navigation bar link to the sites even though they did not have access.

    Obviously, there are situations when users don’t have permissions to a site and you don’t want them to see that the site even exists. An example of this might be in an extranet scenario when you have third parties accessing project sites and you don’t want those third parties seeing the names of other project sites that may exist let alone the content…so how do we prevent this?

    Identifying security trimmed links

    By reviewing the URLs of the links in the top navigation bar I was able to identify whether the links were security trimmed or not. If the field for the URL is disabled then the link is security trimmed and most probably created when as the site was created.

    Custom top navigation link that is not security trimmed
    Custom top navigation link that is not security trimmed
    Security trimmed top navigation link
    Security trimmed top navigation link

    Adding new security trimmed links

    After identifying the problem, I then had to make the existing links security trimmed. I did this in two stages. The first was to make a note of the position of the link that needed to be replaced. I then deleted it from the top navigation bar using the ‘Top Link Bar’ site settings page (_layouts/topnav.aspx). The second stage was then to create the new security trimmed link by using the PowerShell code below.

    Modify the $SPWeb and @(“Site Name”, “/sitename/default.aspx”) arguments as required and run the code for each of the top navigation bar links that need to be security trimmed. Remember the old link will need to be removed and the new one ordered as required.

    Conclusion

    It appears SharePoint, specifically SharePoint Foundation 2010 only honours security trimmed links in the top navigation when the links are created automatically as opposed to being created manually.

    Note: this post specifically targets SharePoint 2010 Foundation which does not include the extended navigation that is included as part of the Publishing feature.

  • Mums delicious brownie recipe aka SharePoint Brownies

    Mums delicious brownie recipe aka SharePoint Brownies

    I have baked these delicious chocolate brownies countless times using an old recipe my mum shared with me many years ago. I’ve even enjoyed them with many a friend, colleagues & customers alike. I often bake these delicious brownies for customers when I’m delivering SharePoint and Microsoft 365 workshops or deployments, hence they have since become known as SharePoint Brownies or Microsoft 365 Brownies or simply the mum’s delicious brownies! Many have asked for me to share the recipe, so here it is…

    Delicious Brownie Recipe

    Ultimately delicious chocolate brownies
    Ultimately delicious chocolate brownies #SharePointBrownies

    Ingredients

    • 140g unsalted butter softened and a small amount for lining the baking tin
    • 200g quality plain chocolate such as Lindt or Hotel Chocolat
    • 200g caster sugar
    • Pinch of sea salt
    • 2 tsp vanilla extract / vanilla paste
    • 2 eggs and 1 egg yolk
    • 85g plain flour

    Method

    1. Preheat oven to 180°c
    2. Line a brownie tin with a small amount of butter (7″ square tin is most suitable)
    3. Melt the butter and chocolate on a slow heat and then allow to cool slightly
    4. Mix in the sugar, a pinch of sea salt and the vanilla stopping once the mixture is a little grainy
    5. Whisk in the eggs and yolk one at a time, stirring each time until blended
    6. Add the flour and beat for a minute or so until thickened and smooth
    7. Pour the mixture into tin and bake for 40-45 minutes until a cocktail stick comes out with moist crumbs
    8. Allow to cool and cut into small rectangles slices

    I hope you enjoy these delicious brownies (#SharePointBrownies #Microsoft365Brownies).

  • ZoomIt for Mac – another screen magnifying utility

    On many occasion, I have been to conferences and on training where the presenter has done a demonstration and used a screen magnifying utility to enlarge part of the display. There are many utilities available that provide this functionality and are typically included with the accessibility option of most operating systems.

    Zoom It working
    Zoom It working

    Having asked many a presenter what they were used to magnify the screen, most pointed in the direction the Sysinternals utility ZoomIt which I have since used. More increasingly I am presenting and doing demonstrations on my Mac which leaves without such as useful utility.

    After a short time reviewing various Apps available, I decided on Zoom It for Mac for a small price of £0.69 in the Mac App store. It sits nicely in the toolbar and allows you to customise the loupe size, zoom and shape through various key shortcuts or from the toolbar menu.

    Zoom It toolbar menu
    Zoom It toolbar menu
    Zoom It Settings
    Zoom It Settings

    Enhance your demonstrations and use a utility like either of the magnifying utilities I’ve mentioned – I sure am!

  • Hiding an empty rich text column in XSLT

    Hiding an empty rich text column in XSLT

    This morning I was trying to create a new style in the itemstyle.xsl stylesheet to use within the content query web part (CQWP). I needed a custom style to display a list of announcements, some of which had content and others didn’t and this style was to improve this output.

    The problem is that the ‘Body’ column of an announcement or more importantly the ‘rich text’ field type is never really empty. Even when the column genuinely empty and has no rich text content, a hidden HTML element (a div) exists and acts as a wrapper for any content. As a result, if you try and use a typical ‘if equals null’ statement to hide the rich text column it won’t work because of this hidden element.

    Examples

    An empty rich text column on SharePoint 2010 always has 37 characters as shown below.

    Empty rich text column in SharePoint 2010
    Empty rich text column in SharePoint 2010

    With SharePoint 2007 the rich text column has 65 characters when empty, again as shown below.

    Empty rich text column in SharePoint 2007
    Empty rich text column in SharePoint 2007

    Solution

    The solution, in the end, was to use the string-length function to determine if the rich text column was longer than the standard 37 characters on SharePoint 2010 as identified above.

  • Working with Managed Paths in SharePoint using PowerShell

    Quite a common requirement for implementations of SharePoint that I am involved in is to create new managed paths for a given web application.

    While it is a simple task to perform via Central Administration, I inevitably turn to PowerShell to achieve this so that I can then include it as part of larger configuration or deployment scripts.

    Define managed paths in Central Administration
    Define managed paths in Central Administration

    To manage managed paths in SharePoint we use the PowerShell Get-SPManagedPathNew-SPManagedPath and Remove-SPManagedPath cmdlets.

    Reviewing existing managed paths

    To get a list of all the managed paths for a given web application we use the Get-SPManagedPath cmdlet as shown below.

    Get-SPManagedPaths PowerShell Cmdlet
    Get-SPManagedPaths PowerShell Cmdlet

    Creating a new explicit path

    Explicit managed paths only allow one site collection to be created at a specific path. An example of this is the root site collection of a web application which has an explicit managed path of “/” (https://sharepoint.jcallaghan.com).

    To add a new explicit managed path to a web application we use the New-SPManagedPath cmdlet and include the -Explicit parameter.

    Adding a wildcard managed path

    Wildcard managed paths allow one or more site collections to exist at a specified path. This is the same as the default ‘sites’ managed path that we should all be familiar with (https://sharepoint.jcallaghan.com/sites/projectxyz).

    To add a wildcard managed path we run the command as we did for an explicit managed path however we don’t include the -Explicit parameter.

    Custom managed paths added
    Custom managed paths added

    Removing an existing managed path

    There may be times when you need to remove managed paths. This can be done by running the Remove-SPManagedPath cmdlet and specifying the name of the managed path to be removed and what web application to remove it from. When removing a managed path you will be prompted to confirm the removal action – this can be silenced by adding -confirm:$false to the command.

    Conclusion

    Using the SPManagedPath nouns in PowerShell we can get a list of existing managed paths, create explicit or wildcard managed paths and also remove existing managed paths for a given web application.

  • Adding a Yes, No, Cancel prompt to a PowerShell script

    When I write PowerShell scripts, I often want to step through sections. This allows me to decided whether to proceed with parts of my script or not. I achieve this by using the ChoiceDescription class as demonstrated below.

    More information about using prompts in PowerShell can be found in the following article and tip on Microsoft TechNet.

  • Clear the SharePoint Quick Launch using PowerShell

    Clear the SharePoint Quick Launch using PowerShell

    Today I had a requirement to remove all the headings and links from the quick launch navigation of hundreds of SharePoint sites. The sites were being provisioned as part of a PowerShell deployment script that was deleting the default list and libraries. Going through each of these sites manually was not an option – so I edited the deployment script to include a function to remove the headings for me.

    SharePoint Quick Launch with Headings
    SharePoint Quick Launch with Headings

    I remembered doing something similar to this back on SharePoint 2007 but I didn’t have access to the previous script or project and instead had to research the subject for a while to find what I needed.

    Solution

    A post from Get-SPScripts supplied me with what I was after, although it was part of a much larger script. So I picked away at their code and made it into the following PowerShell function to re-use in other projects.

    The above Remove-SPQuickLaunchLinks function will remove all headings and links from the SharePoint quick launch for a particular site.

    Empty SharePoint Quick Launch
    Empty SharePoint Quick Launch

    Remember to review, rename and test this script before using it in a production environment.

  • Backup and download solutions in SharePoint from the configuration database

    Backup and download solutions in SharePoint from the configuration database

    The need to backup or download SharePoint solutions or WSPs from SharePoint come’s up from time to time. This usually crops up for me when upgrading client environments, and they have forgotten where they put their original solutions, or there is a discrepancy as to which version they installed.

    To download the solutions from the config database run the following PowerShell script. This will save all of the solutions stored in SharePoint’s config database to a directory (“C:\Solutions”) on the local machine.

    Remember to review, rename and test this script before using it in a production environment.

  • Review, rename and test

    Review, rename and test

    Review

    It goes without saying…but whenever you download and use any code or script from this site, or any site for that matter, you should review and understand what the code or script is doing before you attempt to use it.

    Rename

    Using the PowerShell scripts that I share as an example. I distribute these scripts as text files as it provides an opportunity to review the script, after which you can knowingly rename the file. This also prevents any hastily or accidental execution of the script.

    Test

    And as with anything you download from the internet – you should test it in a dedicated environment prior to any production environment.

  • Remote Desktop Connection Manager

    When I started my new job a few weeks ago I decided I was going to introduce some new tools and utilities to help myself and my colleagues be more productive. The first one I brought to their attention was Remote Desktop Connection Manager (RDCMan) from Microsoft.

    Remote Desktop Connection Manager (RDCMan)
    Remote Desktop Connection Manager (RDCMan)

    I’ve known about this tool for almost a year now but it always surprises me how few administrators out there don’t know about this tool. It’s a must-have for any System Administrator using mstsc.exe or Remote Desktop to manage more than one server or computer!

    RDCMan manages multiple remote desktop connections. It is useful for managing server labs where you need regular access to each machine such as automated check-in systems and data centres. It is similar to the built-in MMC Remote Desktops snap-in but more flexible.

    Remote Desktop Connect Manager can be downloaded directly from the Microsoft Download Centre.

    Please also say a big thank you to Julian Burger the developer at Microsoft who wrote this awesome tool and David Zazzo for working to get it released! You can read about how David discovered Julian’s RDCMan tool within an internal Microsoft repository and worked to get it licensed for external distribution on the Exchange TechNet Blog.

  • Amazingly delicious molten chocolate muffins

    Amazingly delicious molten chocolate muffins

    I just used this recipe to make these tasty muffins for everyone in the office – I do like to treat them all every once in a while. These muffins should be eaten as soon as they have had a moment to cool in order to experience the delicious molten chocolate inside. They are great on their own but worth trying with a scoop or two of vanilla ice cream or served with alcoholic Chantilly cream.

    Makes: 16
    Prep: 15min
    Cook: 20min

    Ingredients

    • 4tbsp soft margarine
    • 55g / 2oz caster sugar
    • 1 large egg
    • 85g / 3oz self-raising flour
    • 1tbsp cocoa powder
    • 55g / 2oz plain chocolate
    • Icing sugar, for dusting

    Method

    1. Preheat oven to 190°C / 375°F and prepare 8 muffin cases by placing them in a muffin tray or even on a baking tray.
    2. Whisk the margarine, sugar, egg, flour and cocoa together in a large bowl until just smooth.
    3. Spoon half of the batter mix into the muffin cases. Break the chocolate evenly into 8 squares and place a piece in each of the half-filled cases, then spoon the remaining batter mix on top.
    4. Bake the cupcakes for 20 minutes until well risen and springy to the touch. Let them stand for two or three minutes and dust with icing sugar before serving warm to experience the deliciously yummy molten chocolate.
  • Why WordPress and not SharePoint?

    Why WordPress and not SharePoint?

    Many people have said to me “your using WordPress for your blog but you’re a SharePoint Consultant” and my response is typical “but why must use SharePoint – I guess you also have a problem with me using a Mac?”.

    Yes, I do work with SharePoint – in fact, it goes beyond just working with it but we won’t go there. I have developed websites for many years and typically chosen to build these on the WordPress platform – it’s adaptable and responsive to the differing requirements and yet it doesn’t need weeks of custom development. Not only that but it was built for blogging and the user interface is more in tune to writing blog posts. Secretly I knew if I used SharePoint for my blog it would become more of a job than a hobby with all the extra work it would need.

    SharePoint is just not the blogging platform for me – let’s just say when I’m blogging I want the night off!