Windows Server 2016-查询并导出固定时间段创建AD用户

生产环境中往往我们有各式各样的需求,例如快速查询某段时间创建用户,或批量导出固定时间段创建用户列表,具体操作如下:

$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

小温

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: