Hi, I'm trying to pass the windowsemailaddress field from the get-mailbox command using the Exchange 2007 Powershell to another part of a script.
Unfortunately, when I use something like:
Get-Mailbox | select WindowsEmailAddress
Get-Mailbox | fl WindowsEmailAddress
it passes the column heading and some other weird characters to the variable. The actual code I'm using is included.
How can I pass raw email addresses to the next part of the script? ie. like they were from a text file and each smtp address was on a new line, no spaces or carrage returns etc.
$AllAddresses = Get-Mailbox | select WindowsEmailAddress
foreach($userEM in $AllAddresses)
$setPPTo = "0"
$casUrl = "https://fsatg10ech001/ews/exchange.asmx"
$ewc = new-object EWSUtil.EWSConnection("migrator2@# removed by modernmatt #",$true, $null, $null, $null,$casUrl)
$fldarry = new-object EWSUtil.EWS.BaseFolderIdType 1
$dTypeFld = new-object EWSUtil.EWS.DistinguishedFolderIdType
$dTypeFld.Id = [EWSUtil.EWS.DistinguishedFolderIdNameType]::msgfolderroot
$mbMailbox = new-object EWSUtil.EWS.EmailAddressType
$mbMailbox.EmailAddress = $mbMailboxEmail
$dTypeFld.Mailbox = $mbMailbox
$fldarry = $dTypeFld