1.获取密码即将过期用户的信息,90天有效期的话,获取过期前7天的密码
Get-ADUser -filter * -searchbase "ou=OUname,dc=contoso,dc=com" -Properties *|where {($_.passwordlastset -lt (Get-Date).adddays(-83)) -and ($_.passwordneverexpires -ne "True")}|select name,samaccountname >>e:\seven.csv
2.通过导入CSV文件批量创建域账号
Import-CSV "d:\filename" |ForEach-Object {$setpass=convertto-securesting -asplaintext $_.pwd -Force;New-ADUser -SamAccountName $_.alias -GivenName $_.ln -Surname $_.ln -DisplayName $_.name -userprincipalname ($_.alias+"@dangdang.com") -Description $_.desc -Department $_.dept -Office $_.office -AccountPassword $setpass -Enabled $True}
3.查询在指定日期创建的账号
Get-ADUser -Filter * -Properties *|Where-Object {$_.created -gt (Get-Date).adddays(-3) -and $_.created -lt (get-date).adddays(-2)}|select distinguishedname,created>>e:\lz\AdUsercreated4.csv