Granting Permissions on Mailboxes using Power shell

If you have some accounts which needs to have full access permission on hundreds of mailboxes then following power shell command is for you. By using following steps you can add set of users to hundreds of mailboxes in single shot.

In order to use this command you have to perform below steps;

1. Create one csv file name it users.csv and save it to C:\ drive.

2. Type text "name" in first line. Please make sure that there is no space or any other special character after text "name" otherwise the command will not run.

3. Copy all user ids (of mailboxes) on which you want to add permissions after text "name" in same column.

4. Open Exchange Management Shell and type following command and press enter;

Import-CSV "C:\users.csv" | ForEach{Add-MailboxPermission –ID $ –AccessRights FullAccess –User [Account id]}

Replace [Account id] with the account id which you want to grant full access permissions on mailboxes.

for verifying that the permissions has been granted, Run following command;

Import-CSV "C:\users.csv" | ForEach{Get-MailboxPermission –ID $ –User [Account id}

You can add more columns in you text file if you want by using comma ‘,’ and can reference it in the command as same as you are referencing the first column.

If you don’t have aliases or Ids and have only display names and these display names are in last name first name format such as smith, john then you have to add your names in your .csv file like this “smith, john”

if you want to do opposite and wants to add full access permission for lots users on one mailbox then following will be your command

Import-Csv c:\users.csv | foreach {Add-MailboxPermission –Identity [Account Id] -User $_.users -Accessright Fullaccess -InheritanceType all}

Replace [Account Id] with the mailbox alias or name.

The above command is one of the demonstration of the "power" of powershell and we can see that how much it has reduced the administration efforts in terms of mailbox management.

Comments (0)

Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.