Powershell获取世纪互联Office365所有用户最后一次登录时间

 1 #$Mails=get-mailbox -ResultSize 10

 2 $Mails=get-mailbox -ResultSize Unlimited

 3 $Mails | Measure-Object

 4 

 5 $i=0

 6 

 7 foreach ($Mail in $Mails) 

 8 {

 9 $i=$i+1

10 $mailbox=Get-MailboxStatistics $Mail.UserPrincipalName

11 $content=-join($i,"`t",$Mail.UserPrincipalName,"`t",$mailbox.LastLogonTime)

12 #echo $content

13 $contents=-join($contents,$content,"`n")

14 }

15 

16 Start-Transcript -path .\Office365LastLogon.csv -Append -Force

17 $contents

18 Stop-Transcript 

http://www.smallrascal.cn/smallrascal/article.asp?id=2085

你可能感兴趣的:(powershell)