The following Google Apps Script is designed to bulk set permissions on a Shared drive. It has been created as a standalone Function that requires the ID of the Shared drive and manually entered email addresses for the relevant permsisions.
This is how I first worked with it to learn what information was required and how to structure the content, before combining it all into a Google Sheet tool which will be blogged about in the near future.
Enable Drive API Service
Make sure you have followed the instructions here to enable the Drive API Service.
The Code
Below are some comments about snippets of the code to better understand what is happening.
We need to create a JavaScript Object that contains the relevant Shared drive permissions and email addresses as arrays. There are some blank values in this example to show that not every type of role needs something in it:
var roles = {
organizer: ["example1@example.com"], // Manager
fileOrganizer: ["example2@example.com"], // Content Manager
writer: ["example3@example.com", "example4@example.com"], // Contributor
reader: [ ] // Viewer
};