Office 365 Last Logon Script

Hello Guys

I need to retrieve the list of users ( UPN,Email Address, Lastlogontime) who didn't access the mailbox older than 60 days in Exchange Online.

I have the script which retrieves the displayname but i want the output with UPN, email address , Lastlogontime who didn't access the mailbox older than 60 days.

Kindly assist me with script on this.

Regards

rokinth

September 2nd, 2015 11:40am

Hi,

If you're already getting output, just add the other attributes.

PS - you forgot to post your script, so there's not a way for us to offer any additional suggestions.

Free Windows Admin Tool Kit Click here and download it now
September 2nd, 2015 11:42am

Script

$mb= get-mailboxrecipienttypedetail usermailbox -resultsize unlimited
$rest = @()
foreach($mb1 in $mb){$rest+=Get-MailboxStatistics -Identity $mb1.primarysmtpaddress| select-object displayname,lastlogontime;[System.Threading.Thread]::Sleep(500)}
$gt=get-date
$inactloggin= $rest | where{($_.LastLogonTime -ne $null) -and ($gt.subtract($_.LastLogonTime).days -ge 61 )}
$Nevlog= $rest | where{$_.LastLogonTime -eq $null}
$allinact=$inactloggin + $Nevlog
$allinact |  select-object displayname,lastlogontime | export-csv inactiveusers.csv -NoTypeInformation

In Get-mailboxstatisctics, it will not retrieve the UPN and Email address. Need your help to get the output with

UPN, email address , Lastlogontime who didn't access the mailbox older than 60 days.

Regards

Rokinth

September 2nd, 2015 11:44am

In Get-mailboxstatisctics, it will not retrieve the UPN and Email address.

You should be able to get those from the $mb1 object.

Free Windows Admin Tool Kit Click here and download it now
September 2nd, 2015 11:58am

$mailboxes=Get-Mailbox -Results Unlimited

$mailboxes | 
    ForEach-Object{
        $lastLogonTime=($_|Get-MailboxStatistics).LastLogonTime
        $_|Add-Member Noteproperty LastLogonTime $LastLogonTime
    }

$mailboxes | 
    Where-Object{$_.LastLogonTime -gt [datetime]::Today.AddDays(-60)}|
    Select UserPrincipalName,DisplayName,LastLogonTime,EmailAddresses


September 2nd, 2015 12:30pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics