In the last IndyConn blog post we covered how we leveraged PowerShell to script the mass creation of Document Libraries within a SharePoint site. This blog post is a continuation to our SharePoint blog series. To see part One of our SharePoint Series, Click Here.
A customer that we have been working with has a SharePoint environment consisting of several hundred sites. They recently created a new AD Group that they wanted to add Read-Only access to a list of SharePoint sites they had specified.
We created a CSV file containing the list of the URLs for the SharePoint Sites. For example:
https://indy.sharepoint.com/sites/SITE1
https://indy.sharepoint.com/sites/SITE2
https://indy.sharepoint.com/sites/SITE3
We then ran the PowerShell commands below specifying the AD Group they had provided for the $user variable:
This script can also be leveraged to assign Site Owners or Site Members by updating the Get-PnpGroup switch like this:
To assign to Site Owners, use -AssociatedOwnerGroup
To assign to Site Members, use -AssociatedMemberGroup
To assign to Site Visitors, use -AssociatedVisitorGroup
By using the above PowerShell script, we were able to quickly assign an AD Group to the SharePoint Site permissions for hundreds of sites. We hope you found this to be useful. Be sure to watch for our next blog for more tips and information!