• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 214
  • 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
  • 2
1 Solution
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

techdriveAuthor Commented:
oh I see and I noticed that you did not need to use the @{add} array thanks.
@{add="email@email.com"}  is used with parameter -EmailAddresses to add additional email addresses.
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.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

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