Connect-SPOService –Url "YOUR ADMIN SITE HERE"
# Get all sites
Get-SPOHubSite
#SO YOU CAN GET THE ID YOU NEED
# add users to a security group
$hubSiteId= "HUB ID HERE"
$sites = Get-SPOSite -Limit ALL
foreach ($site in $sites)
{
$siteDetailed = Get-SPOSite -Detailed $site.Url
if($siteDetailed.HubSiteId -eq $hubSiteId)
{
$site.Url
$x = Get-SPOSiteGroup -Site $site.url
foreach ($y in $x)
{
if($y.Title -like "*Owners*") #OR GROUP YOU NEED
{
$group = Get-SPOSiteGroup -Site $site.URL -Group $y.Title
$group.title
Add-SPOUser -Site $site.url -LoginName "FULL EMAIL OF USER" -Group $group.title
}
}
}
}
No comments:
Post a Comment