SOLVED

Hub Site PowerShell: SPO vs PnP

%3CLINGO-SUB%20id%3D%22lingo-sub-227950%22%20slang%3D%22en-US%22%3EHub%20Site%20PowerShell%3A%20SPO%20vs%20PnP%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-227950%22%20slang%3D%22en-US%22%3E%3CP%3EI'm%20creating%20some%20reusable%20scripts%20for%20provisioning%20a%20hub%20with%20connected%20sites%2C%20but%20there%20are%20cmdlets%20for%20hub%20sites%26nbsp%3Bthat%20appear%20to%20serve%20the%20same%20purpose%20with%20slight%20differences%20in%20application%26nbsp%3B%3CEM%3E(e.g.%26nbsp%3B%3CSTRONG%3ERegister-SPOHubSite%3C%2FSTRONG%3E%20and%26nbsp%3B%3CSTRONG%3ERegister-PnPHubSite%3C%2FSTRONG%3E).%20%3C%2FEM%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhat%20would%20be%20the%20reasoning%20behind%20having%20both%2C%20will%20these%20merge%20going%20forward%20and%20should%20I%20use%20one%20set%20over%20another%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-291133%22%20slang%3D%22en-US%22%3ERe%3A%20Hub%20Site%20PowerShell%3A%20SPO%20vs%20PnP%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-291133%22%20slang%3D%22en-US%22%3EI%20am%20using%20both%20when%20I%20provision%20sites.%20I%20have%20been%20using%20the%20PnP%20for%20many%20years%20since%20the%20SPO%20ones%20have%20been%20lacking%20a%20lot%20of%20functionality.%3CBR%20%2F%3EThe%20cmdlets%20you%20specify%2C%20Register-SPOHubSite%20and%20Register-PnPHubSite%20is%20an%20example%20where%20I%20am%20using%20the%20PnP%20version.%3CBR%20%2F%3EThe%20reason%20is%20that%20the%20PnP%20version%20has%20the%20option%20to%20not%20specify%20the%20parameter%20-Principals.%3CBR%20%2F%3EThe%20SPO%20version%20has%20this%20parameter%20as%20mandatory.%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-227978%22%20slang%3D%22en-US%22%3ERe%3A%20Hub%20Site%20PowerShell%3A%20SPO%20vs%20PnP%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-227978%22%20slang%3D%22en-US%22%3E%3CP%3ESharePoint%20Online%20can%20be%20accessed%20with%20two%20type%20of%20PowerShell%20commands%2C%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fsharepoint%2Fsharepoint-online%2Fintroduction-sharepoint-online-management-shell%3Fview%3Dsharepoint-ps%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3ESharePoint%20Online%20Cmdlets%20%3C%2FA%3Eand%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fsharepoint%2Fsharepoint-pnp%2Fsharepoint-pnp-cmdlets%3Fview%3Dsharepoint-ps%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3ESharePoint%20PnP%20Cmdlets%3C%2FA%3E.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3ECmdlets%20contains%20-SPO%3C%2FSTRONG%3E%20are%20from%20SharePoint%20Online%20Cmdlets%3B%20which%26nbsp%3Bcomes%20from%20%3CSTRONG%3ESharePoint%20Online%20Management%20Shell%3C%2FSTRONG%3E.%3C%2FP%3E%3CP%3E%3CSTRONG%3ECmdlets%20contains%20-PnP%3C%2FSTRONG%3E%20are%20from%20%3CSTRONG%3ESharePoint%20PnPPowerShell%3C%2FSTRONG%3E%20Cmdlets%3B%20which%20is%20a%20open%20source%20and%20it%20contains%20modules%20to%20access%20both%20SharePoint%20Online%20and%20SharePoint%20On-Premises.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3ESPO%20vs%20PnP%3C%2FSTRONG%3E%3A%3C%2FP%3E%3CUL%3E%3CLI%3EPnP%20PowerShell%20Cmdlets%20contains%20additional%20parameters%20to%20each%20command%2C%20which%20is%20used%20to%20achieve%20more%20tasks%20when%20compared%20to%20equivalent%20SPO%20command.%26nbsp%3B%3C%2FLI%3E%3CLI%3EPnP%20PowerShell%20Cmdlets%26nbsp%3B%20managed%20by%20Patterns%20and%20Practices%20team%20and%20it%20gets%20updated%20every%20month.%20Where%20as%20SPO%20cmdlets%20are%20windows%20PowerShell%20module%20to%20manage%20the%20SharePoint%20Online%20and%20this%20also%20get%20frequent%20updates.%3C%2FLI%3E%3CLI%3EPnP%20PowerShell%20Cmdlets%20works%20in%20the%20context%20of%20the%20current%20user%2C%20where%20as%20SPO%20command%20runs%20with%20the%20Tenant%20Admin%20rights.%3C%2FLI%3E%3CLI%3EPnP%20PowerShell%20Cmdlets%20connects%20to%20the%20SiteCollection%20level%2C%20where%20as%20SPO%20has%20the%20commands%20to%20target%20Tenant%20level.%3C%2FLI%3E%3C%2FUL%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EEach%20has%20its%20own%20advantages.%20If%20you%20want%20to%20run%20the%20scripts%20on%20SiteCollection%20and%20Current%20User%20context%2C%20go%20with%20PnP%20PowerShell.%20By%20using%20PnP%20PowerShell%2C%20you%20can%20also%20reuse%20the%20scripts%20for%20On-Premise%20environment.%20For%20now%2C%20On-Premise%20doesn't%20have%20hub%20related%20features.%3C%2FP%3E%3CP%3EBut%20If%26nbsp%3Bhave%20the%20scripts%20to%20target%20Tenant%20level%20and%20require%20Tenant%20level%20admin%2C%20go%20with%20SharePoint%20Online%20Commands.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
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
Highlighted
Solution

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.

 

 

 

 

Highlighted
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.