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.
User generated image
However running the script above does not. It returns multiple values when stored in a variable.
User generated image

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
ASKER CERTIFIED SOLUTION
Avatar of SubSun
SubSun
Flag of India image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Joseph Daly
Joseph Daly
Flag of United States of America image

ASKER

Looks like adding the .tostring worked.
Exchange
Exchange

Exchange is the server side of a collaborative application product that is part of the Microsoft Server infrastructure. Exchange's major features include email, calendaring, contacts and tasks, support for mobile and web-based access to information, and support for data storage.

213K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo