Link to home
Start Free TrialLog in
Avatar of jack jones
jack jones

asked on

get email attribute from object value - Powershell

is it possible to get corresponding email attribute from object property of user
Avatar of Adam Brown
Adam Brown
Flag of United States of America image

Yes. Email addresses are stored in the proxyaddresses attribute in Active Directory. There is also an email attribute that can contain the user's primary email address, but this is an informational attribute only and is what controls the EMail field in the user properties screen.
Avatar of jack jones
jack jones

ASKER

do u have a script
get-aduser JustAnExample -Property ProxyAddresses | Select -Expand ProxyAddresses
This gives error..
$user = "canonicalname path"
Get-ADUser -Filter { CN -eq $user } -Properties *| Select displayname,emailaddress

Open in new window

Then it's wrong.
You do not need to use a filter when wanting an exact CN match.
And you should not use -Property * - be restrictive, otherwise the cmdlet has to retrieve a lot of data unnecessarily.
Get-AdUser 'canonicalname path' -Property EMailAddress | Select DisplayName, EmailAddress

Open in new window

how about querying for multiple canonical paths? how to query foreach in that case
This also give error
Get-AdUser 'canonicalname path' -Property EMailAddress | Select DisplayName, EmailAddress

Open in new window

Get-AdUser : Cannot find an object with identity: 

Open in new window

SOLUTION
Avatar of Qlemo
Qlemo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I have a canonical name i want to get mail id associated with it..
its like "domainname/someOU/someOU/username"
so im trying to query
domainname/someOU/someOU/username

Open in new window

to get mail id
we can easily query a displayname to get this but can we use canonical name
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I have recommended this question be closed as follows:

Split:
-- Qlemo (https:#a42225972)
-- Qlemo (https:#a42225275)


If you feel this question should be closed differently, post an objection and the moderators will review all objections and close it as they feel fit. If no one objects, this question will be closed automatically the way described above.

Pber
Experts-Exchange Cleanup Volunteer