question

frob avatar image
0 Votes"
frob asked JoyZ commented

In SharePoint Online - What PowerShell can grant an Azure-AD-Security-Group, Owner permissions on all site collections?

Hi there

In SharePoint Online - What PowerShell can grant an Azure-AD-Security-Group, Owner permissions on all site collections?

Thank you.

office-sharepoint-onlinewindows-server-powershell
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

JoyZ avatar image
0 Votes"
JoyZ answered JoyZ commented

@frob-0826,

We can use PnP powershell to meet your requirement, please check as following(remember to change the group id, tenant name and user for yourself):

 #Set Parameter
 $AdGroupID = "9009dee4-6a70-412b-992f-0d107fca4c27"
 $LoginName = "c:0t`.c`|tenant`|$ADGroupID"
    
 $SiteUrl="https://tenant.sharepoint.com/"
 $UserName="julie@tenant.onmicrosoft.com"
 $cred = Get-Credential -UserName $UserName -Message "Please enter password for $UserName"
 Connect-PnPOnline -Url $SiteUrl -Credentials $cred
    
     
 #Get all site collections
 $Sites = Get-PnPTenantSite
    
 Foreach ($Site in $Sites)
 {
     Connect-PnPOnline -Url $Site.Url -Credentials $cred
     $Groups=Get-PnPGroup
     foreach($Group in $Groups){
         if ($Group.LoginName -like "*Owners"){
            Add-PnPGroupMember  -LoginName $LoginName -Identity $Group
         }
     }
 }

If an Answer is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Great! What is meant by this snippet c:0t`.c`|tenant`, please? Will I have to change this to match my environment?

Thank you.




0 Votes 0 ·

@frob-0826,

This is the claim type for the group, no need to change it.

0 Votes 0 ·