none
Exporting days since LastLogonTime RRS feed

  • Question

  • I'm succesfully exporting the LastLogonTime for mailboxes, however when I'm trying to add a column to the export which contains the number of days since the last logon, I'm stuck.

    Get-MailboxStatistics $mbx.alias | where {$_.LastLogonTime -lt $time -AND $_.WhenMailboxCreated -lt $time} | 
       Select-Object displayname,lastlogontime,lastloggedonuseraccount,@{Name="ReferenceDate"; Expression={($datetoday)}},
       @{N='MailboxDaysInactive'; E={$($(Get-Date) - $([DateTime]::FromFileTime($_.LastLogonTime))).Days}} | Export-CSV -Path "D:\Exports\ExportTestMail.csv -NoTypeInformation -Append

    I'm using the following line succesfully for Get-ADUser with the LastLogon attribute, but with Get-MailboxStatistics (with the correct LastLogonTime attribute) the result is empty in the export.

    @{N='MailboxDaysInactive'; E={$($(Get-Date) - $([DateTime]::FromFileTime($_.LastLogonTime))).Days}}

    Friday, March 24, 2017 12:58 PM

All replies

  • Hi,

    Please go through below link it will help you.

    https://arstechnica.com/civis/viewtopic.php?t=1162152 

    Friday, March 24, 2017 1:05 PM
  • Hello Hardik_Patel, thanks for your answer. Could you motivate this answer for my situation? I still don't really understand how this information can help me solve my question.
    Monday, March 27, 2017 8:20 AM