troubleshooting Question

Exchange 2010 powershell store primary smtpaddress in a variable

Avatar of Joseph Daly
Joseph DalyFlag for United States of America asked on
ExchangePowershellWindows Server 2008
2 Comments1 Solution2342 ViewsLast Modified:
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

Running the command get-mailbox hutchl | select-object primarysmtpaddress returns the results as I expect.
select-object
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.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros