生產(chǎn)環(huán)境中往往我們有各式各樣的需求,例如快速查詢某段時間創(chuàng)建用戶,或批量導(dǎo)出固定時間段創(chuàng)建用戶列表,具體操作如下:
$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