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?