Exchange 2010--Powershell Question

In setting up the following PS Script:

$List = import-csv D:\user.csv
Get-mailbox $List.Name

I get an output of mailbox information of my entire Exchange organization when I simply want the information of these few users.

My csv is:

What might be the issue?
Anthony K O365Asked:
Who is Participating?
SubsunConnect With a Mentor Commented:
Try this
$list=import-csv D:\User.csv
Foreach ($i in $list) {
 $Grp= get-distributiongroup My_DG
	$manage = $Grp.managedby
	$Newuser = Get-User $
	$Newmanage = $manage+$Newuser
 Set-distributiongroup $Grp.identity -managedby $Newmanage -bypasssecuritygroupmanagercheck 

Open in new window

Manpreet SIngh KhatraSolutions Architect, Project LeadCommented:
What do you want exactly ?

- Tancy
Anthony K O365Author Commented:
I want to import a csv file and add these users to the ManagedBy permission in this DG, using following PS:

$list=import-csv D:\User.csv
Foreach ($i in $list) {
 $newuser=get-mailbox $
 Set-distributiongroup My_DG -managedby $newuser -bypasssecuritygroupmanagercheck }

any thougths?
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

Manpreet SIngh KhatraSolutions Architect, Project LeadCommented:
Get-Content D:\User.csv |  Set-distributiongroup My_DG -managedby "UserName" -bypasssecuritygroupmanagercheck

- Rancy
Anthony K O365Author Commented:
Here is the error I get when

PS] D:\>./manageby.ps1
Cannot process argument transformation on parameter 'Identity'. Cannot convert value "" to type "Microsoft.Exchange.Configuration.Tasks.UserIdParameter". Error: "Parameter values of type Microsoft.Exchange.Configuration.Tasks.UserIdParameter can't be empty. Specify a value, and try again.
Parameter name: identity"
    + CategoryInfo          : InvalidData: (:) [Get-User], ParameterBindin...mationException
    + FullyQualifiedErrorId : ParameterArgumentTransformationError,Get-User

All groups must have at least one owner who manages membership, message approval, and other settings for the group. Make sure you assign an owner for this group.
    + CategoryInfo          : NotSpecified: (:) [], RecipientTaskException
    + FullyQualifiedErrorId : A34ABEE7
Manpreet SIngh KhatraSolutions Architect, Project LeadCommented:
What is the command you ran did you provide the username and remove quotes ?

- Rancy
Anthony K O365Author Commented:
Your last suggestion worked!  However, it still produced the error message "cannot convert the value "" to type...

My csv did not have any quotes. Go figure...

You have lot of trouble with CSV files.. :-).. I didn't see any issue with script.. Can you post the csv file which you used? probably it has some blank lines..
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.