Hub Site PowerShell: SPO vs PnP

New Contributor

I'm creating some reusable scripts for provisioning a hub with connected sites, but there are cmdlets for hub sites that appear to serve the same purpose with slight differences in application (e.g. Register-SPOHubSite and Register-PnPHubSite).


What would be the reasoning behind having both, will these merge going forward and should I use one set over another?

2 Replies
best response confirmed by Susan Zhu (New Contributor)

SharePoint Online can be accessed with two type of PowerShell commands, SharePoint Online Cmdlets and SharePoint PnP Cmdlets.


Cmdlets contains -SPO are from SharePoint Online Cmdlets; which comes from SharePoint Online Management Shell.

Cmdlets contains -PnP are from SharePoint PnPPowerShell Cmdlets; which is a open source and it contains modules to access both SharePoint Online and SharePoint On-Premises.


SPO vs PnP:

  • PnP PowerShell Cmdlets contains additional parameters to each command, which is used to achieve more tasks when compared to equivalent SPO command. 
  • PnP PowerShell Cmdlets  managed by Patterns and Practices team and it gets updated every month. Where as SPO cmdlets are windows PowerShell module to manage the SharePoint Online and this also get frequent updates.
  • PnP PowerShell Cmdlets works in the context of the current user, where as SPO command runs with the Tenant Admin rights.
  • PnP PowerShell Cmdlets connects to the SiteCollection level, where as SPO has the commands to target Tenant level.


Each has its own advantages. If you want to run the scripts on SiteCollection and Current User context, go with PnP PowerShell. By using PnP PowerShell, you can also reuse the scripts for On-Premise environment. For now, On-Premise doesn't have hub related features.

But If have the scripts to target Tenant level and require Tenant level admin, go with SharePoint Online Commands.





I am using both when I provision sites. I have been using the PnP for many years since the SPO ones have been lacking a lot of functionality.
The cmdlets you specify, Register-SPOHubSite and Register-PnPHubSite is an example where I am using the PnP version.
The reason is that the PnP version has the option to not specify the parameter -Principals.
The SPO version has this parameter as mandatory.