Powershell Cmd to extract all mailbox, all M365 license and all date of last access of mailbox

Raymond Tan 6 Reputation points
2021-09-20T01:49:54.82+00:00

Hi All,

Good day. Appreciate if any kind soul can help to extract the below,

  1. all mailbox
  2. all M365 license
  3. all date of last access of mailbox

Thanks

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,390 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Limitless Technology 39,396 Reputation points
    2021-09-20T14:01:28.413+00:00

    Hello,

    Thanks for reaching out,

    Get-MsolUser -All | Where-Object {($_.licenses).AccountSkuId -match "ENTERPRISEPREMIUM"} | ft
    --To list all users using (consuming) a specific licensing plan, use the following command:

    Get-Mailbox -ResultSize unlimited | Format-Table DisplayName,
    --To get all Mailboxes

    Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | Select-Object DisplayName,LastLogonTime
    --To bet all mailboxes lastaccess or last logon time

    Hope this helps.