0

On a SharePoint Online site, you can access this menu through Site Permissions -> Advanced Permissions Settings -> Grant Permissions.

enter image description here

I have a Microsoft security group created, and my goal is to give this group Full Control of these sites without making the group a member of the site. I can share the site in this way using the menu above, but is there a way to do this using PowerShell?

1 Answer 1

0

Please run the below PowerShell script as admin:

Step 1: Get Azure Security Group’s ID

#Install AzureAd package
Install-Module AzureAD

$GroupName = "ADGroup" 
#Connect to Azure AD
Connect-AzureAD -Credential (Get-Credential)

#Get Security Group's SID
Get-AzureADGroup -SearchString $GroupName | Select DisplayName, ObjectId | Format-table

enter image description here

Step 2: Add Azure Security Group to SharePoint Online Site Collection Administrator’s Group

#Variables
$AdminURL = "https://tenant-admin.sharepoint.com/"
$SiteURL = "https://tenant.sharepoint.com/sites/Echo"
$ADGroupID = "a5c7f51f-1544-45fe-9679-ad99ed6d53ac"
 
$LoginName = "c:0t`.c`|tenant`|$ADGroupID"
 
Try {
    #Connect to SharePoint Online
    Connect-SPOService -url $AdminURL -Credential (Get-Credential)
  
    $Site = Get-SPOSite $SiteURL
  
    Write-host -f Yellow "Adding AD Group as Site Collection Administrator..."
    Set-SPOUser -site $Site -LoginName $LoginName -IsSiteCollectionAdmin $True
    Write-host -f Green "Done!"
}
Catch {
    write-host -f Red "Error:" $_.Exception.Message
}

enter image description here

enter image description here

1
  • Thanks for the answer. At first I was having difficulty with this, but it was only because I forgot to add myself as a member to the AD group as well as an owner.
    – Allen Cook
    Jul 13, 2021 at 14:18

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.