Add-MailboxPermission for multiple users on multiple mailboxes

I have a need to grant a large number of users full access to an equally large number of mailboxes. I've previously been able to do this easily in the management shell where I have multiple users for one mailbox (or vice-versa; one user for multiple mailboxes) by using one of the following 2 commands:

get-content c:\xxxx.txt | foreach { Add-MailboxPermission $_ -User user.name -AccessRights FullAccess}

or

get-content c:\xxxx.txt | foreach { Add-MailboxPermission examplemailbox -User $_ -AccessRights FullAccess}

This works fine for when there are only multiple entries on one side of the equation, but using this method, I would need to run the command multiple times to get all of the accesses set up as requested. So I've been looking to see if there is a way of writing one command that could achieve it all in one go.

What I've been looking at doing is creating a .csv file, filled as such;

name,mail

user.name1,mailbox1

user.name2,mailbox2

And then writing a shell command like the below:

import-csv c:\xxxx.csv | foreach { Add-MailboxPermission $_.mail -User $_.name -AccessRights FullAccess}

Will this achieve the result that I'm aiming for? or is it going to be easier to just go with the more time-consuming method of just having the multiple entries on one side of the equation?

February 13th, 2015 6:18pm

yes that will work.


Free Windows Admin Tool Kit Click here and download it now
February 13th, 2015 11:45pm

Hi,

I have a test in my environment, you can use the following cmdlet to grant multiple users full access to multiple mailboxes.

Import-csv c:\test1.csv | foreach { Add-MailboxPermission $_.mail -User $_.name -AccessRights FullAccess}

For example, if I want to grant amy02, amy03 full access permission to amy01; grant amy01, amy02 full access permission to amy03, the test1.csv file should be:

Hope this can be helpful to you.

Best regards,

February 15th, 2015 9:55am

Thanks for this! Had to list all of the users next to each of the mailboxes they needed access to (rather than a column of the users and another column of the mailboxes, with each only mentioned once), but it worked! A bit more work required to fill up the data on the CSV file, but still a lot quicker than running multiple commands each time.

Many thanks.

Free Windows Admin Tool Kit Click here and download it now
February 16th, 2015 6:57am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics