I've built a PowerShell 5.1 script to export all the users in the DB and save all the data in to a CSV file. The script allows you to set a date back in time so you can decide since when you'd like your users to be exported.
After some testing a realized that not all the users are exported, and upon further investigation I realized that the property
WhenCreated are not present for each user. Despite the AD UI showing the property with the right data, as seen in the screenshot bellow.
When I run the following command:
Get-ADUser -filter * -Properties LastLogonDate, userPrincipalName, initials, WhenCreated, whenChanged | Select-Object userPrincipalName, initials, whenCreated, whenChanged
I get the following result:
userPrincipalName initials whenCreated whenChanged ----------------- -------- ----------- ----------- 11/9/2017 2:06:29 PM 1/24/2018 4:26:48 PM 11/9/2017 2:07:47 PM 11/22/2017 4:12:52 PM firstname.lastname@example.org MP 11/14/2017 3:14:45 PM 2/14/2018 4:02:51 AM email@example.com DG 11/15/2017 12:51:25 PM 2/21/2018 2:12:52 PM firstname.lastname@example.org AE email@example.com MM firstname.lastname@example.org RW email@example.com KK firstname.lastname@example.org AP email@example.com JS firstname.lastname@example.org CB 11/17/2017 12:21:32 PM 11/22/2017 4:41:35 PM email@example.com firstname.lastname@example.org TT
As you can see the user with the initials TT has no value despite the screenshot showing that it has them. Despite me creating this user today, and changing few values the same day.
- What am I missing?
- Is it a problem with AD itself or just the command?