0

I have 53 client sites.

Is there a way I can add the same permissions for one group as members for all sites as well as give access to individual email addresses (external users) with a certain permissions level.

I'm looking to script this whole thing into one PS script and run it instead of going on each site and making all these changes 53 times. Each site already has the permission level created.

Any help would be great.

0

Are you using an AD Security Group for the users? You can use Set-PnPWebPermission cmdlet to set permissions for the group (identity) according to the following syntax:

Set-PnPWebPermission -Url https://xyz.sharepoint.com/sites/abc -Group 'Group A' -AddRole 'Contribute'

Documentation about the cmdlet can be found here: https://docs.microsoft.com/en-us/powershell/module/sharepoint-pnp/set-pnpwebpermission?view=sharepoint-ps

0

Here is a sample (PnP PowerShell) script to add user/group as member to multiple sites:

#Define Sites List
$Sites = "<site1URL>",
"<site2URL>",
"<site3URL>"
 
#Loop Through Each Site 
ForEach ($URL in $Sites){
    #Connect to Site
    Connect-PnPOnline -Url $URL -UseWebLogin
     
    #Get the Default Members Group
    $MembersGroup = Get-PnPGroup -AssociatedMemberGroup
 
    #Add User to Group
    Add-PnPUserToGroup -Identity $MembersGroup -EmailAddress "<groupname>"
    Write-host "Added User to Site:"$URL
}

If the 53 client sites are all the sites in your tenant, use Get-PnPTenantSite for the Define Sites List section instead.

Reference: SharePoint Online: Add User to Group using PowerShell.

For external users, they need to be invited and added to the organization directory before you use the same method to assign user permission. Note to use the Username of external users (with organization domain name) instead of actual email adsressesaddresses.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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