Thursday, August 30, 2007

Who logged on to my mailbox?

 

This on-liner lists all mailboxes and the user account that was the last to open it.

get-mailbox  | select name, @{n="LastLoggedOnUser";e={(Get-MailboxStatistics -id $_).LastLoggedOnUserAccount}}

 

Name               LastLoggedOnUser
------                ----------------------
Administrator   HOMELAB\Administrator
Shay                 HOMELAB\Shay
User1               HOMELAB\Administrator
User2               HOMELAB\User2
User3               HOMELAB\User3

 

As you can see, the Administrator account was the last user to open User1's mailbox.

 

UPDATED:

Actually here is a better one :)

# ? = where-object
# ft -a = format-table -autosize

>> Get-MailboxStatistics | ? {$_.objectclass -eq "mailbox"} | select DisplayName,Last* | ft -a

 

DisplayName   LastLoggedOnUserAccount   LastLogonTime              LastLogoffTime
-----------        -----------------------             -------------                    --------------
Administrator HOMELAB\Administrator       30/08/2007 12:32:40    30/08/2007 12:51:40
Shay               HOMELAB\Shay                    30/08/2007 12:13:11    30/08/2007 12:43:20
User1             HOMELAB\Administrator       18/05/2007 00:33:40    18/05/2007 00:33:40
User2             HOMELAB\User2                   18/05/2007 00:32:40    18/05/2007 00:32:40
User3             HOMELAB\User3                   18/05/2007 00:31:40    18/05/2007 00:31:40

No comments: