Back to previous page

Apply SPFx extensions to SharePoint Hub Sites using PnP PowerShell

Hub sites bring a set of common functions to all sites that belong the hub, but extensions are not propagated to all sites automatically.

With PnP PowerShell is possible to automate the installation of Application Customizers through the sites, the script below search for all sites associated with hub and apply the custom action to all of them.

Before running the script, you will need to have PnP PowerShell installed, the latest version can be installed from here.

Artificial intelligence science class.

The scripts will not install the extension using ALM APIs, in order to get this working, you need to install the extension manually on the global app catalog.

Installing

Before running the script, you need to adjust the main variables to your own values:

  • tenantAdmin = “https://contoso-admin.sharepoint.com”
  • hubSite = “https://contoso.sharepoint.com/sites/hub”
  • extensionGUID = “6da1a9e8-471d-4f39-80e6-a7ded02e8881”
  • extensionName = “Extension Name”
  • extensionTitle = “Extension Title”

You can get your extension GUID from the extension project, open the manifest.json and copy the id value.

 

 

The execution of the script will identify all the sites belonging to the Hub and will print if the installation was achieved with success.

Searching SharePoint Hub sites

Uninstalling

In case you want to remove the extensions from all the hub sites I’m also providing a script to do it, but the extension must be installed with the same name in all sites.

Every time an extension is installed a new identifier for the extension is generated and the removal requires that id, it can be retrieve using PowerShell if we know in advance what was the installation name.

Before running the script, you need to adjust the main variables to your own values:

  • tenantAdmin = “https://contoso-admin.sharepoint.com”
  • hubSite = “https://contoso.sharepoint.com/sites/hub”
  • extensionName = “Extension Name”

 

The execution of the script will identify all the sites belonging to the Hub and will print if the uninstall was achieved with success.

Searching SharePoint hub sites

Conclusion

PnP PowerShell comes handy to automate processes on modern SharePoint especially when there are no graphical interfaces available, a must-have for every SharePoint administrator

Reference:
Ferreira, J. (2018). Apply SPFx extensions to SharePoint Hub Sites using PnP PowerShell.  Available at http://sharepoint.handsontek.net/2018/05/13/apply-spfx-extensions-to-sharepoint-hub-sites-using-pnp-powershell/  [Accessed: 15 May 2018]

Share this on...

Leave a Reply

Back to previous page