生产环境中往往我们有各式各样的需求,例如快速查询某段时间创建用户,或批量导出固定时间段创建用户列表,具体操作如下:
$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-Objectname,samaccountname,Givenname,surname,Displayname,distinguishedName,userPrincipalName,title,mobile,telephoneNumber,employeeNumber,postalCode,whenCreated,company,department,streetAddress|Export-CsvC:azureyunuser2019.csv-EncodingUTF8–NoTypeInformation