Solved

powershell exchange 2010

Posted on 2014-01-30
3
194 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
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…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

758 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now