Add-Mailboxpersmission for multiple users

Posted on 2010-08-25
Medium Priority
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 $_.name -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
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

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 2000 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 = $_.name
$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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month11 days, 15 hours left to enroll

752 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