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.
However running the script above does not. It returns multiple values when stored in a variable.
All I am trying to do is store the primarysmtpaddress into a variable of my choosing.