查询3天内创建邮箱的用户

查询3天内创建邮箱的用户

$d = (Get-Date).adddays(-3)
$ys = Get-ADUser -Filter 'Enabled -eq $true -and msExchWhenMailboxCreated -ne "$null" -and msExchWhenMailboxCreated -ge $d' -Properties msExchWhenMailboxCreated
$ys.Count
#此方式问题:如果用户创建邮箱后删除邮箱,然后再重新创建邮箱,msExchWhenMailboxCreated记录的时候还是第一次创建的时候
使用如下方式准确性较高:

$d = (Get-Date).adddays(-3)
$ys = Get-ADUser -Filter 'Enabled -eq $true -and mail -ne "$null" -and WhenChanged -ge $d' -Properties WhenChanged,mail,msExchWhenMailboxCreated
$ys|select samaccountname,mail,whenchanged,msExchWhenMailboxCreated
$ys.Count

 

posted on 2022-06-28 14:02  momingliu11  阅读(38)  评论(0编辑  收藏  举报