principiamanagement
asked on
How to take inventory of all email address (of contacts, usernames, DLs) from Exchange Server. my server hosts many domains so need a complete list of existing emails
i used the script from below URL, works very well.
http://exchangepedia.com/2005/09/how-to-export-all-email-addresses-from-a-domain.html
But the result comes in below format
cn: Performance Log Users
mail: PerformanceLogUsers@xxxxxx
Proxy Addresses
SMTP:PerformanceLogUsers@x
smtp:PerformanceLogUsers@x
smtp:PerformanceLogUsers@x
I want to have the email addresses in the below format
Username1, SMTPAddress,smtpaddress1,s
Excluding X.400 smtpaddress
Many thanks
SK
Sorry, I just realized, that you have Exchange 2003. I'll give you a Quest Active Server Role Snapin version soon.
ASKER
Ok thanks Soostibi..
SK
SK
So this is the Quest AD snapin PowerShell version. I hope you are familiar with it. (http://www.quest.com/powershell/activeroles-server.aspx )
Get-QADUser -LdapFilter "(mailnickname=*)" | %{
$mb = $_
$primary = $mb.proxyaddresses | ?{$_ -clike "SMTP*"} | ForEach-Object {$_ -replace "^SMTP:",""}
$others3 = @($mb.proxyaddresses | ?{$_ -clike "smtp*"} | Select-Object -First 3)
New-Object -TypeName PSObject -Property @{
UserName = $mb.name
PrimarySMTP = $primary
SMTPAddress1 = $(if($others3.count -ge 0){$others3[0]}else{""})
SMTPAddress2 = $(if($others3.count -ge 1){$others3[1]}else{""})
SMTPAddress3 = $(if($others3.count -ge 2){$others3[2]}else{""})
}
} | Select-Object Username, PrimarySMTP, SMTPAddress1, SMTPAddress2, SMTPAddress3 | Export-Csv c:\yourpath\yourfile.csv
A bit nicer:
Get-QADUser -LdapFilter "(mailnickname=*)" | %{
$mb = $_
$primary = $mb.proxyaddresses | ?{$_ -clike "SMTP*"} | ForEach-Object {$_ -replace "^SMTP:",""}
$others3 = @($mb.proxyaddresses | ?{$_ -clike "smtp*"} | ForEach-Object {$_ -replace "^smtp:",""} | Select-Object -First 3)
New-Object -TypeName PSObject -Property @{
UserName = $mb.name
PrimarySMTP = $primary
SMTPAddress1 = $(if($others3.count -ge 0){$others3[0]}else{""})
SMTPAddress2 = $(if($others3.count -ge 1){$others3[1]}else{""})
SMTPAddress3 = $(if($others3.count -ge 2){$others3[2]}else{""})
}
} | Select-Object Username, PrimarySMTP, SMTPAddress1, SMTPAddress2, SMTPAddress3 | Export-Csv c:\yourpath\yourfile.csv
ASKER
hi, thanks for the script and just one question before running it, will this include emails from contacts list.
We have a cheaper Axigen box and some users are sitting on that box and there is only contacts available for those users in Active Directory
thanks again
SK
We have a cheaper Axigen box and some users are sitting on that box and there is only contacts available for those users in Active Directory
thanks again
SK
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Wow that worked like a charm...
Also can you help me with a one script to include contacts, users, groups...
Excellent work!
Many Thanks
SK
Also can you help me with a one script to include contacts, users, groups...
Excellent work!
Many Thanks
SK
This includes groups and an additional column describing the object type, such as user, group or contact. Also more precise on users: does not include disabled and system users.
Get-QADObject -LdapFilter "(&(mailnickname=*)(|((&(objectcategory=person)(!(userAccountControl:1.2.840.113556.1.4.803:=2))(!userAccountControl=2080)))(objectClass=contact)(objectClass=group)))" | %{
$mb = $_
$primary = $mb.proxyaddresses | ?{$_ -clike "SMTP*"} | ForEach-Object {$_ -replace "^SMTP:",""}
$others3 = @($mb.proxyaddresses | ?{$_ -clike "smtp*"} | ForEach-Object {$_ -replace "^smtp:",""} | Select-Object -First 3)
New-Object -TypeName PSObject -Property @{
ObjectType = $mb.objectclass | Select-Object -Last 1
UserName = $mb.name
PrimarySMTP = $primary
SMTPAddress1 = $(if($others3.count -ge 0){$others3[0]}else{""})
SMTPAddress2 = $(if($others3.count -ge 1){$others3[1]}else{""})
SMTPAddress3 = $(if($others3.count -ge 2){$others3[2]}else{""})
}
} | Select-Object ObjectType, Username, PrimarySMTP, SMTPAddress1, SMTPAddress2, SMTPAddress3 | Export-Csv c:\yourpath\yourfile.csv
And you modify the last portion to:
| Export-Csv c:\yourpath\yourfile.csv -notypeinfromation
This way it's easier to open with Excel.
| Export-Csv c:\yourpath\yourfile.csv -notypeinfromation
This way it's easier to open with Excel.
Sorry, typo:
| Export-Csv c:\yourpath\yourfile.csv -NoTypeInformation
| Export-Csv c:\yourpath\yourfile.csv -NoTypeInformation
ASKER
hi Soostibi... you rock! That's exactly what I wanted...
thanks
SK
thanks
SK
Open in new window