whenz
asked on
Exchange PowerShell: Get all Primary SMTP Addresses of members of Distribution List
I have following script to export primary smtp addresses of a particular distribution list:
The output of the command is:
I would like to have following output (without header and " characters):
$HelloMailboxes = "HelloMailboxes"
$PathExportMailboxes = "C:\upload\HelloMailboxes.csv"
Get-DistributionGroupMember $HelloMailboxes | Select PrimarySmtpAddress | Export-Csv $PathExportMailboxes -NoTypeInformation
The output of the command is:
"PrimarySmtpAddress"
"mary@haylock.ch"
"marie@haylock.ch"
"leandro@haylock.ch"
"buchhaltung@haylock.ch"
"bibliothek@haylock.ch"
I would like to have following output (without header and " characters):
mary@haylock.ch
marie@haylock.ch
leandro@haylock.ch
buchhaltung@haylock.ch
bibliothek@haylock.ch
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Another option..
Get-DistributionGroupMember $HelloMailboxes | %{$_.PrimarySmtpAddress.ToString()} >C:\Group.txt
This can be done from ADUC , where as you can create a query to get all the users and then from add and remove coloumn , you can add email address and then export the list to a csv file.
If you have the Saved query folder in teh Active Directory Users and computers Snap-in then you can do this:
1. Right-Click the folder and select New query
2. Give it a descriptive name
3. Click Define Query
4. From the drop down list select Custom Search
5. Clcik Advanced tab
6. Paste in the following:
(&(objectCategory=user)(me mberOf=cn= Domain Admins,cn=users,dc=YourDom ain,dc=loc al))
You will need to change the cn=..... part to suite your groups distinguished name.
then once you save this and get a list you can:
7. Right-click on your query
8. Select Export List (not Export Query definition as this just creates a backup of the query)
9. Select from the save as type:
Text (Comma Delimited) (*.csv)
Which of course, opens in Excel as it is.
Cheers
Dash
If you have the Saved query folder in teh Active Directory Users and computers Snap-in then you can do this:
1. Right-Click the folder and select New query
2. Give it a descriptive name
3. Click Define Query
4. From the drop down list select Custom Search
5. Clcik Advanced tab
6. Paste in the following:
(&(objectCategory=user)(me
You will need to change the cn=..... part to suite your groups distinguished name.
then once you save this and get a list you can:
7. Right-click on your query
8. Select Export List (not Export Query definition as this just creates a backup of the query)
9. Select from the save as type:
Text (Comma Delimited) (*.csv)
Which of course, opens in Excel as it is.
Cheers
Dash
Herein Attached a Script for o make it easier for you.
What does the script exactly do?
1- Queries Active Directory for Contacts & Groups
2- Lists their email addresses
3- Queries Users
4- Lists enabled users’ email addresses
5- Lists disabled users’ email addresses separately (was required for a certain project I did a long time back)
6- Outputs to command line and also to a text file – c:\proxyaddresses.txt
- X.400 addresses are ignored
ListEmailAddresses.zip
What does the script exactly do?
1- Queries Active Directory for Contacts & Groups
2- Lists their email addresses
3- Queries Users
4- Lists enabled users’ email addresses
5- Lists disabled users’ email addresses separately (was required for a certain project I did a long time back)
6- Outputs to command line and also to a text file – c:\proxyaddresses.txt
- X.400 addresses are ignored
ListEmailAddresses.zip
ASKER