Friday, August 28, 2015

Reporting Exchange Attributes of the AD Object

Hi folks,

This little code will help you to report the Exchange related attributes from your AD accounts and export them into the CSV file.

So imagine a scenario where you have a bunch o test accounts which start with TST for which you need to report their recipient type information. This is where Get-AdUser cmdlet comes to help. Of course you may modify your filter according to the attribute to filter on or you can use -Filter * to output all the users. Alternatively you can filter by display name or any other attribute that fits your purpose better.

When creating report for clarity sake i used samAccountName and DisplayName to identify my mailbox-enabled users as well as msExchRecipientDisplayType  and msExchRecipientTypeDetails as I was hunting for those values. Again any Exchange or non-Exchange user attributes can be used. You can refer here as a good cheat list for the user AD attributes as a reference. And of course don't forget to import PowerShell module for AD.

Import-Module ActiveDirectory
Get-ADUser -Filter {sAMAccountName -like "TST*"} -Properties * |select samAccountName,DisplayName,msExchRecipientDisplayType,msExchRecipientTypeDetails |Export-Csv Report.csv


Enjoy!

No comments:

Post a Comment