View Single Post
Old 10-02-2008   #3 (permalink)
Jacob Saaby Nielsen


 
 

Re: find email address

Hello AHartman,

sure you can.

You can choose one of two ways, at least with Quest's AD commandlets.

This is one way of getting the primary e-mail address:

Get-QADObject -SizeLimit 0 | where {$_.Email -ne $null} | select name, email

If you're looking for all the users e-mail addresses (users may have more
than one registered to them),
then you can use this:

Get-QADObject -SizeLimit 0 -IncludedProperties ProxyAddresses | where
{$_.proxyaddresses -ne $null} | select name, proxyaddresses

That, however, returns a whole collection of e-mail addresses per object,
where SMTP is the primary e-mail
address, and the smtp ones are the secondary ones.

There's an even faster way of doing it though. But it's a bit quirky
(haven't had time to find out why, but my
experience is that it is...)

This is how you get all of the users email addresses via the same cmdlet,
but using an LDAP query instead:

Get-QADObject -SizeLimit 0 -ldapfilter '(ProxyAddresses=*)' | where
{$_.EmailAddresses -ne $null} | select name, EmailAddresses

And, if you just need the primary email address:

Get-QADObject -SizeLimit 0 -ldapfilter '(mail=*)' | where {$_.Email -ne
$null} | Select Name, Email

Whichever you decide to use is fine. They provide the same output (afaik).
But the LDAP query is faster.

Remember that the Get-QADobject returns ALL types of objects. If you're just
looking for users, either use
the -Type parameter (-Type user/group/publicfolder), or use the Get-QADuser
cmdlet instead

As for the SQL, I don't do that myself. But there is this:

http://www.sqljunkies.com/WebLog/mar.../28/27237.aspx

Hope that helped !

--
Kind Regards,
Jacob Saaby Nielsen
http://www.ijacob.info

PowerShell trouble ? http://www.powershellcommunity.org
Quote:

> I have a sql table that has employee names but has there full name
> like
>
> Rice, Jim A.
>
> Is there a way to read AD to get there Smtp email address and update
> that Sql table?
>

My System SpecsSystem Spec