Add-Mailboxpersmission for multiple users

Posted on 2010-08-25
Last Modified: 2012-08-13

I have this csv file:

fred;hans, piet, jan
now i want to do the following:

i want to give the users under "access" rights on the user under "name"

Import-CSV -delimiter (";") $CSVFile | ForEach-Object -Process {

$users = $_.access
$users = $users.replace(", ",',')
$users = $users.Split(",")
$users | get-aduser | Add-MailboxPermission -Identity $_.Name -AccessRights 'FullAccess'
$users | get-aduser | Add-ADPermission -Identity $ -ExtendedRights 'Send-as'

which doenst work..
Add-MailboxPermission : The input object cannot be bound to any parameters for the command either because the command d
oes not take pipeline input or the input and its properties do not match any of the parameters that take pipeline input
any got an idea how to do this?


Question by:Hans de Jongh
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 28

Expert Comment

ID: 33524791
If all the users are in a OU - userOUName, can you try:

get-mailbox -organizationalunit "userOUName" | add-mailboxpermission -User FullName -AccessRights FullAccess -InheritanceType All

Author Comment

by:Hans de Jongh
ID: 33524947
thanks but they arent
LVL 28

Expert Comment

ID: 33524976
Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

LVL 32

Expert Comment

ID: 33525159
Import-CSV -delimiter (";") $CSVFile | ForEach-Object {
$delegates = $_.Access.Split(",");
foreach($d in $delegates) { Add-MailboxPermission $_.Name $d };
LVL 13

Accepted Solution

soostibi earned 500 total points
ID: 33525256
The Add-MailboxPermission accepts input from the pipeline for the -Identity parameter (see the help), but it does not for the -user parameter. So you have to pass the parameter value to the relevant parameter 'manually' by a Foreach-object cmdlet for that. And because you can not have two different $_ variables (nested pipes), you have to copy it to a temporary variable ($mailbox). So the result:

Import-CSV -delimiter (";") $CSVFile | ForEach-Object -Process {

$users = $_.access
$users = $users.replace(", ",',')
$users = $users.Split(",")
$mailbox = $
$users | foreach-object {Add-MailboxPermission -Identity $mailbox -AccessRights 'FullAccess' -user $_}
$users | foreach-object {Add-MailboxPermission -Identity $mailbox -ExtendedRights 'Send-as' -user $_}

Open in new window


Author Closing Comment

by:Hans de Jongh
ID: 33525893
thanks again master!!! works great!

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently, Microsoft released a best-practice guide for securing Active Directory. It's a whopping 300+ pages long. Those of us tasked with securing our company’s databases and systems would, ideally, have time to devote to learning the ins and outs…
Uncontrolled local administrators groups within any organization pose a huge security risk. Because these groups are locally managed it becomes difficult to audit and maintain them.
This video discusses moving either the default database or any database to a new volume.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question