Solved

Add-Mailboxpersmission for multiple users

Posted on 2010-08-25
6
4,402 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
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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

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…
A list of top three free exchange EDB viewers that helps the user to extract a mailbox from an unmounted .edb file and get a clear preview of all emails & other items with just a single click on mailboxes.
To show how to generate a certificate request 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 Servers >> Certificates…
In this Micro Video tutorial you will learn the basics about Database Availability Groups and How to configure one using a live Exchange Server Environment. The video tutorial explains the basics of the Exchange server Database Availability grou…

828 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