-
-
Save constructor-igor/e80e24c5501c3a222283 to your computer and use it in GitHub Desktop.
[Microsoft.Office.Interop.Outlook.Application] $outlook = New-Object -ComObject Outlook.Application | |
$entries = $outlook.Session.GetGlobalAddressList().AddressEntries | |
$count = $entries.Count | |
$count | |
foreach($entry in $entries) | |
{ | |
[console]::WriteLine("{0}: {1}", $entry.Name, $entry.GetExchangeUser().MobileTelephoneNumber) | |
} |
how do we get custom attribute 1 from GetExchangeUser() ??
If you want to access the attributes of the user, use the (.) notation, to access more properties.
The function GetExchagneUser() will try to go online and find a user with that name instead of just using the data you already have in the variable.
Example:
$entry.Manager.Name
Can someone help me expand on this code? What I would like to do is only hit the exchange server 1 time and also look for a specific filter like "title" and "location" I've modified this code slightly to create an object but there is 62,000 + contacts on my GAL. I'd like to only search for contacts with a specific title and then also a specific location / city. Below is my updated code, but when I run it, it still continues to try to pull all 62,000+ contacts. Is there a way to insert filters on what I'm looking for without pulling all the contacts?
`[Microsoft.Office.Interop.Outlook.Application] $outlook = New-Object -ComObject Outlook.Application
$entries = $outlook.Session.GetGlobalAddressList().AddressEntries
$count = $entries.Count
$count
$objs = @()
foreach($entry in $entries)
{
$attributes = $entry.GetExchangeUser()
$city = $attributes.city
$title = $attributes.jobtitle
$email = $attributes.primarySMTpaddress
$name = $attributes.name
$obj = [pscustomobject]@{
Name = $name
City = $city
Title = $title
Email = $email
}
$objs += $obj
#[console]::WriteLine("{0}: {1}", $entry.Name, $entry.GetExchangeUser().primarySMTPaddress)
}`
Is this problem solved?
Thanks for the code , I can use it.
My GAL is under 20K so I just iterate thru $entries multiple times
how do we get custom attribute 1 from GetExchangeUser() ??