View Single Post
Old 10-01-2008   #2 (permalink)
Jason


 
 

Re: find email address

I get the email address from AD for an email lookup script I use like this:
function send-htmlemail ([string]$GLOBAL:user) {
$user = get-qaduser $user
$usermail = $user.email
....
...
..
}

This way, I can type in the User name or ID and get the email address.

-Jason

"Jacob Saaby Nielsen" wrote:
Quote:

> Hey,
>
> 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
>
> Hope that helped !
>
> Best regards,
> Jacob
> http://www.ijacob.info
>
> Got a PowerShell question ? Go to http://www.powershellcommunity.org !
>
> "AHartman" <Hoosbruin@xxxxxx> wrote in message
> news:qNednWinksl6WX_VnZ2dnUVZ_sednZ2d@xxxxxx
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