pnp / cli-microsoft365

Manage Microsoft 365 and SharePoint Framework projects on any platform
https://aka.ms/cli-m365
MIT License
926 stars 325 forks source link

Connect and disconnect hub site as SP admin #5970

Open milanholemans opened 7 months ago

milanholemans commented 7 months ago

Currently, we have 2 commands spo site hubsite connect and spo hubsite disconnect. Right now, you need permission to the target site in order to run this command. I suggest we add an extra flag for these two commands:

Option Description
--asAdmin Run the command as admin for sites you don't have permission to.

Endpoint

The following endpoint should do the trick:

POST https://contoso-admin.sharepoint.com/_api/SPO.Tenant/ConnectSiteToHubSiteById
{
  "hubSiteId": "0cb3cff9-0578-4d70-bab4-bd1c796b9365",
  "siteUrl": "https://contoso.sharepoint.com/sites/Marketing"
}

To disconnect a site, use the same request with 00000000-0000-0000-0000-000000000000 as hub site ID.

Adam-it commented 7 months ago

Great suggestion. I don't see any risks or problems. Let's ship it

ADTmux commented 7 months ago

Hey I would like to work on this!

milanholemans commented 7 months ago

Cool thank you @ADTmux!

ADTmux commented 7 months ago

Hey @milanholemans , is there a way I could test spo site hubsite connect command if I do not have a Microsoft account that has admin permissions for my organization?

Jwaegebaert commented 7 months ago

@ADTmux, if you don't have access to any kind of dev tenant then I'm afraid you won't be able to test the command. Admin rights are required especially when working with the SPO.Tenant endpoint.