none
Exporting AD attributes where name of attribute isn't exactly known RRS feed

  • Question

  • Hi all,

    I'm trying to see what MS Exchange attributes are still attached to objects within our AD.

    ie there are some msExch attributes, however I don't know all their names, there are approx. 20+, I just want to grab them all, and export to CSV each attribute and its contents.  What makes it harder is that some of the attributes, for example, msExchPoliciesIncluded, are arrays and don't display in the exported CSV.

    I'd love it if I could get a CSV with a user name, then every attribute that has 'msExch*' in the title and the contents of that attribute, even if an array.

    Get-ADUser -filter * -Properties * | select name,samaccountname,*msexch* | Export-Csv "c:\temp\MSExch_atts.csv"

    Monday, July 8, 2019 2:21 AM

Answers

  • This will get all possible exchange attributes.

    Get-ADObject -SearchBase (Get-ADRootDSE).SchemaNamingContext -Filter * -Properties MayContain,SystemMayContain |
        Select-Object @{n="Attributes";e={$_.maycontain + $_.systemmaycontain}} |
        Select-Object -ExpandProperty Attributes |
        Sort-Object -unique | Where{$_ -match '^msexch'}
    


    \_(ツ)_/

    Monday, July 8, 2019 2:52 AM

All replies

  • That is the only way to do that.

    Get-ADUser -filter * -Properties * | select name,samaccountname,msexch*

    The issue is that you will have to explicitly state all exchange properties that can exist in the select statement or only the ones valid on the first user returned will be displayed.

    "msexch*" will have to become the complete list.


    \_(ツ)_/

    Monday, July 8, 2019 2:30 AM
  • Like this:

    # extract properties from known exchange account and conver to an array
    $props = 'msExchArchiveDatabaseLink
    
    msExchArchiveGUID
    msExchArchiveName
    msExchArchiveQuota
    msExchArchiveWarnQuota
    msExchELCMailboxFlags
    msExchExtensionCustomAttribute1
    msExchHomeServerName
    msExchMailboxGuid
    msExchMailboxMoveSourceUserBL
    
    
    
    msExchMailboxSecurityDescriptor
    msExchMailboxTemplateLink
    
    msExchPoliciesIncluded
    msExchRBACPolicyLink
    
    msExchRecipientDisplayType
    msExchRecipientTypeDetails
    msExchRecipLimit
    msExchTextMessagingState
    msExchUMDtmfMap
    msExchUserAccountControl
    msExchUserBL
    
    msExchUserCulture
    msExchVersion
    msExchWhenMailboxCreated
    ' -split "`n" | where{$_}
    
    # add name
    $props += 'Name'
    Get-ADUser -filter * -Properties * | select $prop


    \_(ツ)_/

    Monday, July 8, 2019 2:37 AM
  • This will get all possible exchange attributes.

    Get-ADObject -SearchBase (Get-ADRootDSE).SchemaNamingContext -Filter * -Properties MayContain,SystemMayContain |
        Select-Object @{n="Attributes";e={$_.maycontain + $_.systemmaycontain}} |
        Select-Object -ExpandProperty Attributes |
        Sort-Object -unique | Where{$_ -match '^msexch'}
    


    \_(ツ)_/

    Monday, July 8, 2019 2:52 AM