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 WhenChanged
and 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
mp@mycompany.local MP 11/14/2017 3:14:45 PM 2/14/2018 4:02:51 AM
dg@mycompany.local DG 11/15/2017 12:51:25 PM 2/21/2018 2:12:52 PM
ae@mycompany.local AE
mm@mycompany.local MM
rw@mycompany.local RW
kk@mycompany.local KK
ap@mycompany.local AP
js@mycompany.local JS
cb@mycompany.local CB 11/17/2017 12:21:32 PM 11/22/2017 4:41:35 PM
aw@mycompany.local
tt@mycompany.local 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.
Questions
- What am I missing?
- Is it a problem with AD itself or just the command?