#取出每个数据库最近30分钟登录的用户数量 Add-PSSnapin microsoft.exch* $dbs = Get-MailboxDatabase |sort server foreach ($db in $dbs) { $uinfor = Get-MailboxStatistics -database $db| ? {$_.LastLogonTime -ne $null } | ? {$_.lastlogontime.addminutes(30) -gt (get-date)} $db.name + "," + $db.Server + "," + $uinfor.count |Out-File D:OperationsScriptsms2.csv -Encoding utf8 -Append }