Avatar of gd6627
gd6627Flag for United States of America

asked on 

Extartcting users SMTP addresses

I need to query ad and extract users by display name  and sammaccount and show howmany smtp addresses they have under their account
PowershellActive Directory

Avatar of undefined
Last Comment
Michael B. Smith
Avatar of Zaheer Iqbal
Zaheer Iqbal
Flag of United Kingdom of Great Britain and Northern Ireland image

You can do this via the Exchange Management Shell if you have access

Get-Mailbox -ResultSize Unlimited | Select-Object DisplayName, SamAccountName, PrimarySmtpAddress, @{Name="EmailAddresses";Expression={$_.EmailAddresses | Where-Object {$_.PrefixString -ceq "smtp"} | ForEach-Object {$_.SmtpAddress}}} | Export-CSV c:\EmailAddresses.csv -NoTypeInformation -Encoding Unicode
Avatar of gd6627
gd6627
Flag of United States of America image

ASKER

no I don't have exchange console I have an extended schema and I can see the proxy address for primary and alias smtp
Avatar of FOX
FOX
Flag of United States of America image

Create a folder named Temp on your c:drive
Run the following command

Get-Aduser -filter * -properties Displayname,Samaccountname,proxyaddresses | Select DisplayName,SamAccountname,Proxyaddresses | Export-csv 'c:\temp\UserResults.csv' -notypeinformation
Avatar of gd6627
gd6627
Flag of United States of America image

ASKER

Hey Fox , Thanks for your repluy but the output CSV does not list the Proxy addressess

see below

Displayname       SamAccountname      Proxyaddresses
      guest-disabled      Microsoft.ActiveDirectory.Management.ADPropertyValueCollection
      localadmin      Microsoft.ActiveDirectory.Management.ADPropertyValueCollection
      krbtgt      Microsoft.ActiveDirectory.Management.ADPropertyValueCollection
Avatar of FOX
FOX
Flag of United States of America image

Where are you running the command from?  This command should be run against AD, this command was not run in Exchange Management Shell. Did you open powershell as an administrator?
Avatar of gd6627
gd6627
Flag of United States of America image

ASKER

Running it from my ISE ps Console i loaded the Actiuve Directory Module . I dont have exchange on Prem am looking at the ADUC properties for the Proxy address and some users have 2 proxy addresses .

When i run the script without exporting the results i see the proxy address its only when i enable the Export that it comes out like that
ASKER CERTIFIED SOLUTION
Avatar of Michael B. Smith
Michael B. Smith
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Active Directory
Active Directory

Active Directory (AD) is a Microsoft brand for identity-related capabilities. In the on-premises world, Windows Server AD provides a set of identity capabilities and services, and is hugely popular (88% of Fortune 1000 and 95% of enterprises use AD). This topic includes all things Active Directory including DNS, Group Policy, DFS, troubleshooting, ADFS, and all other topics under the Microsoft AD and identity umbrella.

86K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo