Hi there
In SharePoint Online - What PowerShell can grant an Azure-AD-Security-Group, Owner permissions on all site collections?
Thank you.
Hi there
In SharePoint Online - What PowerShell can grant an Azure-AD-Security-Group, Owner permissions on all site collections?
Thank you.
@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.
11 people are following this question.