• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 209
  • Last Modified:

powershell exchange 2010

Hey guys thanks for all your help in the past. I am just trying to figure out what am I doing here wrong as I am trying to add a bunch of primarysmtpaddresses for users and this is erroring out on the command line.


Import-Csv c:\temp\importfile.csv  | Foreach-Object {Set-Mailbox $_.username -primarysmtpaddress @{Add='$_primarysmtpaddress'}


username   primarysmtpaddress
username   username@contoso.local
username1  username1@contoso.local
username2  username2@contoso.local
username3  username3@contoso.local
0
techdrive
Asked:
techdrive
  • 2
1 Solution
 
SubsunCommented:
Try by removing the single quotes, it won’t expand the variable.. Then, '.' (dot) is missing in '$_primarysmtpaddress'.

Since you are trying to change the primarysmtpaddress.. try the following..
Import-Csv c:\temp\importfile.csv  | Foreach-Object {Set-Mailbox $_.username -PrimarySmtpAddress $_.primarysmtpaddress -EmailAddressPolicyEnabled $false}

Open in new window

0
 
techdriveAuthor Commented:
oh I see and I noticed that you did not need to use the @{add} array thanks.
0
 
SubsunCommented:
@{add="email@email.com"}  is used with parameter -EmailAddresses to add additional email addresses.
0

Featured Post

Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

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