It’s a one-liner command that I use to find the most common AD attributes including the Creation date, Member Of and OU location. I attached the screenshot as example.
Command:
Get-ADUser -filter * -property name,displayname,MemberOf,description,Title,TelephoneNumber,CanonicalName,whencreated,emailaddress| select Name,
Displayname, @{Name=”MemberOf”;Exp={ ((-join (($_.memberof.split(‘,’)) -like “*cn=*”) ) -replace ‘CN=’,”,”).TrimStart(“,”) }}, Description, Title, TelephoneNumber, @{Name=”OU”;Exp={ $_.CanonicalName.Remove($_.CanonicalName.LastIndexOf($_.Name)-1) }}, Whencreated, Emailaddress
You can export to CSV file with the following commands.
Get-ADUser -filter * -property name,displayname,MemberOf,description,Title,TelephoneNumber,CanonicalName,whencreated,emailaddress| select Name,
Displayname, @{Name=”MemberOf”;Exp={ ((-join (($_.memberof.split(‘,’)) -like “*cn=*”) ) -replace ‘CN=’,”,”).TrimStart(“,”) }}, Description, Title, TelephoneNumber, @{Name=”OU”;Exp={ $_.CanonicalName.Remove($_.CanonicalName.LastIndexOf($_.Name)-1) }}, Whencreated, Emailaddress| export-csv -NoTypeInformation ADuser_Properties.csv