Windows Server 2016-query and export a period of time in the past to create AD users
In a production environment, we often have a variety of requirements, such as quickly querying a certain period of time to create users, or batch exporting a fixed period of time to create a user list, as follows:
$date=Get-Date$oldday= (Get-Date) .AddDays (- 10) Get-ADUser-Filter *-Properties *-SearchBase "OU=syncall,DC=azureyun,DC=com" |? {$_ .whenCreated-le $date-and $_ .whenCreated-ge $oldday} | Select-Object name,samaccountname,Givenname,surname,Displayname,distinguishedName,userPrincipalName,title,mobile,telephoneNumber,employeeNumber,postalCode,whenCreated,company,department,streetAddress | Export-Csv C:\ azureyunuser2019.csv-Encoding UTF8-NoTypeInformation
Welcome to the official account of Wechat: Xiao Wen study Society.