Solved

How to use PS Import-csv to invoke add-mailboxpermission/add-ad-permission for multiple users

Posted on 2010-09-10
9
1,436 Views
Last Modified: 2012-05-10
I am trying to create a command using an import-csv to do the above. I have specified the full path for -identity 'cn=,ou=,dc=,dc=' and using the following link, but it does not seem to work. It seems to run OK, but the permissions are not added. Fairly new to this stuff so go easy please :-)

http://www.experts-exchange.com/Software/Server_Software/Email_Servers/Exchange/A_2874-Granting-Permissions-on-Mailboxes-using-Power-shell.html

From this link :-
http://www.experts-exchange.com/Software/Server_Software/Email_Servers/Exchange/A_2874-Granting-Permissions-on-Mailboxes-using-Power-shell.html

The error I get is :-
Add-MailboxPermission : Cannot bind argument to parameter 'User' because it is
null.
At line:1 char:119
+ Import-Csv c:\scripts\users.csv | foreach {Add-MailboxPermission -Identity 'c
n=,ou=,dc=,dc=' -User  <<<< $_.users -Accessright Fullacces
s -InheritanceType all}
Add-MailboxPermission : Cannot bind argument to parameter 'User' because it is
null.
At line:1 char:119
+ Import-Csv c:\scripts\users.csv | foreach {Add-MailboxPermission -Identity 'c
n=,ou=,dc=,dc=' -User  <<<< $_.users -Accessright Fullacces
s -InheritanceType all}
(NOTE - I have removed the entries for obvious reasons for the object itself).
This looks like it reads the csv file and does not find anything in it ?
I have tried creating the csv file on the server itself using notepad :-
name
name1
name2

save as users.csv

also tried on server

namename1name2

save as csv

also tried creating csv on own machine through excel

name
name1
name2

save as csv - copy over to server

I can get the command to run using individual names without the import-csv, so the naming contexts seem right. Would really appreciate help on this.

Thanks
0
Comment
Question by:TheGeezer2010
  • 5
  • 4
9 Comments
 
LVL 32

Expert Comment

by:endital1097
ID: 33645469
depends on what your column names are but it should be something like the following where the column header is user for the person getting access
Import-Csv c:\scripts\users.csv | foreach-object  { Add-MailboxPermission owner -User $_.user -AccessRights FullAccess }
0
 
LVL 32

Expert Comment

by:endital1097
ID: 33645479
if you could give a sampling of what the csv looks like it would be easier
just the header row, then some made up content for the next row
0
 
LVL 11

Author Comment

by:TheGeezer2010
ID: 33645516
Hi There

It is literally as per the article I gave you in the URL :-

Name
Name1
Name2

The header contains a single column "Name" (row 1), in the same column, underneath are the "Name1" (row 2), "Name2" (row 3).

I hope that explains clearly enough how it is created. If you open this file in Notepad, you see exactly this :-

Name
Name1
Name2

Thanks for the quick response !
0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
LVL 32

Expert Comment

by:endital1097
ID: 33645541
nothing against the article but it is a little confusing

if you are trying to grant several users access to one mailbox use the following:
Import-Csv c:\scripts\users.csv | foreach-object  { Add-MailboxPermission owner -User $_.Name -AccessRights FullAccess }

if you are trying to grant one user access to several mailboxes use:
Import-Csv c:\scripts\users.csv | foreach-object  { Add-MailboxPermission $_.Name -User delegate -AccessRights FullAccess }
0
 
LVL 11

Author Comment

by:TheGeezer2010
ID: 33645847
Hi There

As you can see from my original mail, I have used this command, but get the error shown. I am not doing anything out of the ordinary here, but it looks like the csv file is being read, but not finding anything in it ? Like I say, I have tried to create the csv file in different ways, but none seems to work.
0
 
LVL 32

Accepted Solution

by:
endital1097 earned 125 total points
ID: 33645862
you were using $_.users but your column is name so it should be $_.name
that would explain the null
0
 
LVL 11

Author Comment

by:TheGeezer2010
ID: 33646075
Hi Endital1097

Firstly thanks for your patience in answering my request - as i said, I am new so did not really know how to put the question but looks like it wasn't too bad :-(

You were spot on with your solution and i am happy that i have subscribed to this site !!!

The points are yours !!
0
 
LVL 32

Expert Comment

by:endital1097
ID: 33646089
np, you'll be a powershell wizard before you know it
0
 
LVL 11

Author Closing Comment

by:TheGeezer2010
ID: 33646096
Patient expert - I am new both to Powershell and to Experts Exchange so was a little apprehensive.

Not sure who reads this but looking for good websites about using Powershell !!
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

Suggested Solutions

Title # Comments Views Activity
exchange2007 4 20
Office 365 cutover migration questions 2 33
Exhange 2010 10 34
Keep reminding user of an email ether by calling or text until email is read 8 22
Lotus Notes – formerly IBM Notes – is an email client application, while IBM Domino (earlier Lotus Domino) is an email server. The client possesses a set of features that are even more advanced as compared to that of Outlook. Likewise, IBM Domino is…
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…
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…
how to add IIS SMTP to handle application/Scanner relays into office 365.

785 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