0

I am setting up most of our SharePoint Online project sites using PnP PowerShell and when the project site is ready, I join it to our hub site for projects. The way the hub site is set up, I am the only person that can join the projects to the hub site, but I am not tenant admin so I cannot do the join with PnP PowerShell. I have to do it manually.

However, there are some things I would like to do after the site has joined the hub site and I can do these things with a Power Automate flow. Is there a way to trigger the flow automatically "when a site has joined a hub site"?

2 Answers 2

1

There is no trigger available for "When a site has joined a hub site" in standard SharePoint connector.

There is only one related trigger available with standard SharePoint connector which is: "When a site has requested to join a hub site".

Also, there are few actions related to SharePoint hub sites with standard SharePoint connector, you can check those at: SharePoint Connector

2
  • Can I issue a request to join a hub site from PnP PowerShell? I am thinking that even though join is not done this way for our hub site, perhaps it could still trigger something else.
    – Gunilla
    Dec 9, 2022 at 15:03
  • Not sure about PowerShell. But you can create a hub site association approval flow using Power Automate and when it is approved, you can capture the approval outcome in same flow and create libraries/lists in the site (or whatever operations you want to perform after hub site association/approval) Dec 9, 2022 at 15:58
0

For many large organizations, where there could be one hundred hub sites, all the local work is being done by site collections admins, and the tenant admins do not want to get involved with the details of connecting sites to hub sites. The PnP PowerShell for connecting sites Add-PnPHubSiteAssociation to a hub requires you to connect as tenant admin. That is why I came to think about Power Automate and was hoping it was possible to automate it anyway, even though I do not have tenant admin rights.

But as a site collection admin you can connect the site to a hub site manually using a web browser, so there is no logic behind the decision to require tenant admin permissions for Add-PnPHubSiteAssociation.

However, I found another method to connect sites to the hub site, that I can use from my PowerShell script:

Invoke-PnPSPRestMethod -Url "https://xxx.sharepoint.com/sites/MySite/_api/site/JoinHubSite('GUID-to-Hub-Site')" -Method POST -ContentType "application/json;odata=verbose;charset=utf-8" -Content @{}

This method requires a guid to the hub site, and since Get-PnPHubSite also requires tentant admin rights, it is possible to get the guid using https://xxx.sharepoint.com/sites/HubSiteX/_api/site/id

This does not seem to trigger "When a site has requested to join a hub site". But I can do the rest of the tasks in the PowerShell script.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.