Quantcast
Channel: PowerShell General
Viewing all articles
Browse latest Browse all 10624

Creating a string from a get- command

$
0
0

I'm running this to get the primary SMTP address, I'm looping through a CSV that has a list of all the SamAccountNames that I'm modifying.

$Primary=get-mailbox -Identity $_.SamAccountName | Select-Object -ExpandProperty EmailAddresses | Where-Object {$_.SmtpAddress -ilike "*@york.uk*"} | select SmtpAddress

I want billy@york.uk (which is what I get if I just run the command without the $primary= bit). What I get is a string that looks like this @{SmtpAddress=billy@york.uk}. Which, if that is the string, I think won't work when I try to call that string in the command I have put in below

I've got to swap round the Set as Reply address for 200 users using a command like this

[PS] C:\>Set-Mailbox Paul.Cunningham -EmailAddresses SMTP:paulc@exchange2013demo.com,smtp:paul.cunningham@exchange2013demo.com

In the loop I want to use two stings $primary and $secondary

Set-Mailbox -Identity $_.SamAccountName -EmailAddresses SMTP:$Primary,smtp:$Secondary

So how do I stop the @{smtpAddress=} wrapping around the bit of data I want

Thanks

Jonathan

 


    


Viewing all articles
Browse latest Browse all 10624

Trending Articles