Solved

Add-Mailboxpersmission for multiple users

Posted on 2010-08-25
6
4,454 Views
Last Modified: 2012-08-13
Hello,

I have this csv file:

Name;access
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?

Regrads

Hans
0
Comment
Question by:Hans de Jongh
[X]
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
6 Comments
 
LVL 28

Expert Comment

by:sunnyc7
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
0
 

Author Comment

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

Expert Comment

by:sunnyc7
ID: 33524976
0
Industry Leaders: 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!

 
LVL 32

Expert Comment

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

Accepted Solution

by:
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 = $_.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

0
 

Author Closing Comment

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

Featured Post

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.

Question has a verified solution.

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

A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
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…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…

738 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