[Migrated from MSDN Exchange Dev] Filter Mailboxes on Property 'IsInactiveMailbox'

Lydia Zhou - MSFT 2,371 Reputation points Microsoft Employee
2020-11-30T04:18:14.573+00:00

Note: This case is migrated from MSDN Exchange Server Development forum. Since Exchange Server Development forum mainly discuss issues about Exchange development, and non-developer Exchange has transitioned to Microsoft Q&A for support, we migrated this non-developer question manually to continue the discussion.

Original Post: https://social.msdn.microsoft.com/Forums/office/en-US/04134158-8e92-4b94-8e83-98213274e42e/filter-mailboxes-on-property-isinactivemailbox?forum=exchangesvrdevelopment

I am trying to filter all ACTIVE mailboxes into a variable for the purpose of examining outlook rules for data exfiltration. Currently, all mailboxes are pulled and even with robustcloudcommand I am waiting days for the script to complete. I have tried:

Get-Mailbox -ResultSize unlimited -Filter ($_.IsInactiveMailbox -eq '$False')

Get-Mailbox -ResultSize unlimited | where {$_.IsInactiveMailbox -eq '$False'}

Using 'where', I get zero results in the data set.

Using 'filter', I get 'Cannot bind parameter 'Filter' to the target. Exception setting "Filter": ""False" is not a recognized filterable property. Valid property names are:'

Then it lists 'isinactivemailbox' as a filterable property. I found a post to sort mailboxes by last login but that result doesn't account for things like staff tha tis on leave of absence.

How can I filter and return my active mailboxes only? Thank you for any help! :)


~Eric

Microsoft Exchange Online Management
Microsoft Exchange Online Management
Microsoft Exchange Online: A Microsoft email and calendaring hosted service.Management: The act or process of organizing, handling, directing or controlling something.
4,228 questions
{count} votes

Accepted answer
  1. Andy David - MVP 142.6K Reputation points MVP
    2020-12-01T02:02:45.897+00:00

    Ok, I re-read your original post and I think I was confused on what you were asking. Are you saying that a simple get-mailbox includes the inactive ones as well when it shouldn't?

    I'm not seeing that.

    Try this to make it go faster

    Download , install and use the V2 Exo PS Module:

    https://learn.microsoft.com/en-us/powershell/exchange/connect-to-exchange-online-powershell?view=exchange-ps

    Then run these and see what you get:

    This should only list active mailboxes

    (Get-EXOMailbox -ResultSize unlimited).count  
    

    This should only list active and inactive and be higher than above

    (Get-EXOMailbox -ResultSize unlimited -IncludeInactiveMailbox).count  
    

    This should list only inactive mailboxes and be the difference:

    (Get-EXOMailbox -ResultSize unlimited -InactiveMailboxOnly).count  
    

    If I am not understanding question correctly, let me know!

    1 person found this answer helpful.
    0 comments No comments

3 additional answers

Sort by: Most helpful
  1. Lydia Zhou - MSFT 2,371 Reputation points Microsoft Employee
    2020-11-30T04:42:13.84+00:00

    We can use the following command to list the inactive mailboxes:

    Get-Mailbox -InactiveMailboxOnly | FT DisplayName,PrimarySMTPAddress,WhenSoftDeleted  
    

    Please check this for more details: View a list of inactive mailboxes.


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. Eric Weiner 1 Reputation point
    2020-11-30T19:28:49.41+00:00

    Thank you that is pulling inactive and active as well.


  3. Eric Weiner 1 Reputation point
    2020-12-01T03:21:49.79+00:00

    Correct, at least that is what I thought. I have a count of 20957 when using the get-exomailbox and the count goes to 35604 when i include -includeinactivemailbox.

    I think I see where my confusion come from. When we initially did our migration to exchange online we used a service from quadrotech call archive shuttle. This took mailboxes from a 3rd party archive solution and migrated them. I never realized it created onmicrosoft accounts for these. So all of these were showig in my get-mailbox return, but they have no accounts in our AD and they are not using licenses in 365.

    So I'm an idiot lol. I appreciate your help. I'll work to remove those onmicrosoft accounts in MSOL and verify they become inactive.