Solved

Add-Mailboxpersmission for multiple users

Posted on 2010-08-25
6
4,284 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
6 Comments
 
LVL 28

Expert Comment

by:sunnyc7
Comment Utility
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
Comment Utility
thanks but they arent
0
 
LVL 28

Expert Comment

by:sunnyc7
Comment Utility
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 32

Expert Comment

by:endital1097
Comment Utility
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
Comment Utility
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
Comment Utility
thanks again master!!! works great!
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Synchronize a new Active Directory domain with an existing Office 365 tenant
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
To show how to create a transport rule in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Mail Flow >> Rules tab.:  To cr…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

728 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now