I've been trying to figure out if this is even possible in Powershell. I'm trying to pull a list of all users and their email addresses into an array from the Outlook Global Address List so the resulting output would look like this:
Alice Peters [email protected]
Bob Jackson [email protected]
etc
I'm currently able to pull the information using:
[Microsoft.Office.Interop.Outlook.Application] $galSearch = New-Object -ComObject Outlook.Application
$search = @($galSearch.Session.GetGlobalAddressList().AddressEntries | ForEach-Object {$_.GetExchangeUser().Name; $_.GetExchangeUser().PrimarySmtpAddress})
$search
As you might expect the result is formatted like this:
Alice Peters
[email protected]
Bob Jackson
[email protected]
etc
Is there a way to have them be in pairs and not one above the other?
$galSearch.Session.GetGlobalAddressList().AddressEntries | ForEach-Object GetExchangeUser |Select Name,PrimarySmtpAddress