Solved

powershell exchange 2010

Posted on 2014-01-30
3
199 Views
Last Modified: 2014-01-30
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
Comment
Question by:techdrive
  • 2
3 Comments
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
ID: 39820783
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
 

Author Comment

by:techdrive
ID: 39820892
oh I see and I noticed that you did not need to use the @{add} array thanks.
0
 
LVL 40

Expert Comment

by:Subsun
ID: 39820921
@{add="email@email.com"}  is used with parameter -EmailAddresses to add additional email addresses.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

856 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