Manage SharePoint Hub Sites Using PowerShell

Manage SharePoint Hub Sites Using PowerShell

A SharePoint hub site is a collection of sites that are associated with each other. It acts as a centralized hub for seamless sharing of information among sites, ensuring uniformity in appearance, navigation, theme inheritance, and search functionality. As an administrator, it’s crucial to have efficient methods to manage hub sites in SharePoint Online, and that’s where PowerShell comes in handy. Let’s explore PowerShell cmdlets for managing SharePoint hub sites in this blog.  

This comprehensive guide on SharePoint Online hub site management covers the following topics: 


Create SharePoint Hub Sites Using PowerShell 

 In this example, we are going to learn about creating a new hub site using PowerShell. Follow the below steps. 

  1. Firstly, connect to SharePoint Online environment using PowerShell.
Connect-SPOService -Url  
  1. Next, we have to create a new site. This newly created site will be then registered as a hub site.
New-SPOSite -Url -Title “Contoso Project Management” -Owner [email protected] -StorageQuota 2000

The ‘New-SPOSite’ cmdlet is used in the SharePoint Online environment to create a site that will be used as a hub site. 

  1. Finally, do register the new site as a hub site.
Register-SPOHubSite -Principals $null

The ‘Register-SPOHubSite’ cmdlet allows you to designate a SharePoint site as a hub site by providing the URL of the site you want to register. 

And that’s how you create a SharePoint Online hub site in the organization. 


Register an Existing Site Collection as a Hub Site 

 It’s a known fact that you can convert any existing site into a hub site using Microsoft PowerShell if you’re an Office 365 global admin or SharePoint admin. 

To register an existing site into a hub site, run the following cmdlet. 

Register-SPOHubSite  -Principals $null 

By doing so, you have registered the hub site feature on a ‘Marketing’ site to make it a hub site. 


Obtain a List of All Hub Sites in SharePoint Online 

 To get to know all the SharePoint Online hub sites, execute the following cmdlet. 


The ‘Get-SPOHubSite’ cmdlet lists all the hub sites in the tenant. In the listed hub site, if you still have the deleted hub site, it is because you may have forgotten to run the ‘Unregister-SPOHubSite’ cmdlet. 

The ‘Unregister-SPOHubSite’ cmdlet removes the hub site association from the specified site, which means it will no longer function as a hub site, and the hub site features will be disabled on that site. For further information on this cmdlet, you can refer to the additional information provided below. 


Associate a Site with a Hub Site in SharePoint Online 

As an admin, you need to create an association between a site and a hub site to help users quickly identify and access relevant sites in a structured manner. In such cases, you can run the following cmdlet.  

Add-SPOHubSiteAssociation -Site -HubSite

Above is an example of associating the ‘Management’ site with the ‘Project’ hub site. 

The ‘Add-SPOHubSiteAssociation’ cmdlet is used to create an association between the site and the hub site.  


Associate a Hub Site with Another Hub Site in SharePoint Online 

In addition to associating a site with a hub site, you can also associate both hub sites together. To do so, run the following cmdlet, 

Add-SPOHubToHubAssociation -Source 5b6fd3a3-b015-4eb0-8e00-ba4a3949807d -Target 23a36572-37as-45h3-9058-061k2db4cd26

The ‘Add-SPOHubToHubAssociation’ is a cmdlet used to associate a hub site with another hub site in SharePoint Online environment. 

Here the source and target parameters refer to the unique identifier (GUID) of the source hub site and target hub site respectively. 


Remove Association Between a Site and a Hub Site 

In some cases, you want to remove the association between a site and a hub site. By then, you can run the following cmdlet. 

Remove-SPOHubSiteAssociation -Site

By running this cmdlet, you removed the association between the ‘Management’ site from the ‘Project’ hub site.   

The ‘Remove-SPOHubSiteAssociation’ cmdlet is used to remove the site from its associated hub site in the SharePoint Online environment. This cmdlet is currently in preview.


Grant Rights to Associate a Site with a Hub Site 

By default, hub sites in SharePoint Online are publicly accessible. However, administrators have the ability to customize permissions, allowing them to restrict which users or mail-enabled security groups can associate a site with a hub site.  

To grant rights to users or mail-enabled security groups to associate a site with a hub site, run the following cmdlet, 

Grant-SPOHubSiteRights -Principals [email protected] -Rights Join

By running the above cmdlet, you can grant ‘Stefen’ the right to associate his sites with the ‘Project’ hub site. 

This ensures that only authorized users have the ability to connect a site to a hub site, providing better control and security in your SharePoint Online environment. By using the ‘Get-SPOHubSite cmdlet’, you can find out which users or groups have permission to a site. 


In addition to granting permissions to associate the site with the hub site, admins also have the ability to manage permissions to revoke them. When you revoke permissions, the specified principals will no longer associate sites with hub sites. 

Run the following cmdlet to revoke rights for specified principals. 

Revoke-SPOHubSiteRights -Principals [email protected]

The permission to associate the site with the hub site ‘Project’ has been revoked for user ‘Stefen’. 

The Revoke-SPOHubSiteRights cmdlet allows SharePoint administrators to revoke the rights of specified principals (users or groups) to associate a site with a hub site. 


Modify the Name, Logo, and Description of Hub Sites 

Admins can edit hub site information such as name, logo, and description based on the requirements. These modified properties will appear in the SharePoint user interface. 

Set-SPOHubSite “Project Management” -LogoUrl -Description "Hub for the Project Management"

This example demonstrates how to customize the name and logo of a hub in the SharePoint user interface, along with a description for the hub (optional). 

If the site doesn’t exist, this cmdlet returns a “File not found” error. 


Disable the Hub Site Feature on a Site 

 Admins can disable the hub site feature on a site by running the following cmdlet. 

Unregister-SPOHubSite -Identity

The above example explains the disabling of the hub site feature on the ‘Project’ site. Once the hub site has been demoted, all related sites under it become “orphaned”. Orphaned sites don’t have any sites associated with it. 

However, it may take up to an hour for the associated sites to reflect the changes. To expedite the process, you can use the Remove-SPOHubSiteAssociation cmdlet to remove the associated sites beforehand. It doesn’t mean they’re gone; users can still access them through the URL or SharePoint dashboard in Office 365. 

Further, find the list of audit log events recorded for hub site activities. 

Operation Description 
HubSiteJoined  When a site owner associates their site with a hub site. 
HubSiteRegistered  When a site gets registered as a hub site. 
HubSiteUnjoined  When a site owner disassociates their site from a hub site. 
HubSiteUnregistered  When a hub site is unregistered, it no longer functions as a hub site. 


HubSiteOrphanHubDeleted  When an orphaned site gets deleted. 


That’s all about SharePoint hub site management using PowerShell. I hope this blog provides you with valuable insights into effective hub site administration along with SharePoint permission settings. If you have any queries, you can reach us through the comment section! 

Manage SharePoint Hub Sites Using PowerShell

by Praba time to read: 6 min