Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1292
  • Last Modified:

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:
Name
joe.smith@domain.com
Sue.smith@domain.com
Jane.doe@domain.com

What might be the issue?
0
Anthony K O365
Asked:
Anthony K O365
  • 3
  • 3
  • 2
1 Solution
 
Manpreet SIngh KhatraSolutions Architect, Project LeadCommented:
What do you want exactly ?

- Tancy
0
 
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 $i.name
 Set-distributiongroup My_DG -managedby $newuser -bypasssecuritygroupmanagercheck }
 

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

- Rancy
0
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.

 
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
0
 
SubsunCommented:
Try this
$list=import-csv D:\User.csv
Foreach ($i in $list) {
 $Grp= get-distributiongroup My_DG
	$manage = $Grp.managedby
	$Newuser = Get-User $i.name
	$Newmanage = $manage+$Newuser
 Set-distributiongroup $Grp.identity -managedby $Newmanage -bypasssecuritygroupmanagercheck 
}

Open in new window

0
 
Manpreet SIngh KhatraSolutions Architect, Project LeadCommented:
What is the command you ran did you provide the username and remove quotes ?

- Rancy
0
 
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...

Thanks!
0
 
SubsunCommented:
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..
0

Featured Post

Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

  • 3
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now