Avatar of Joseph Daly
Joseph DalyFlag for United States of America asked on

Exchange 2010 powershell store primary smtpaddress in a variable

I am trying to write a simple script however I am coming across a strange problem. I would like to store the primarysmtpaddress value in a variable. The code I am using is below which i thought would be very simple but it isnt working as i expected.

$user = get-mailbox hutchl
$mainemail = $user.primarysmtpaddress

Open in new window

Running the command get-mailbox hutchl | select-object primarysmtpaddress returns the results as I expect.
However running the script above does not. It returns multiple values when stored in a variable.
stored in variable

All I am trying to do is store the primarysmtpaddress into a variable of my choosing.
ExchangePowershellWindows Server 2008

Avatar of undefined
Last Comment
Joseph Daly

8/22/2022 - Mon
Subash Sundharan

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Joseph Daly

Looks like adding the .tostring worked.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes