Exclude inactive mailboxes from all org holds

Bartosz Filipczak 1 Reputation point
2021-08-24T14:33:09.783+00:00

Hi all! We're trying to exclude all inactive mailboxes from all org holds (retention policy) to convert them to temporary (183 days by design) soft-deleted state to allow them to be auto-purged after that time. We created this so far:

$Inactive = Get-Mailbox -InactiveMailboxOnly -Filter "(LitigationHoldEnabled -eq 'false')" # that's correct, we get the correct value in this variable. We want to get inactive AND not under litigation

$Inactive | foreach {Set-Mailbox -Identity $_ -ExcludeFromAllOrgHolds} # that's not correct, it gives "cannot process argument transformation on parameter 'Identity'. Cannot convert value "INACTIVE" to type..."

any ideas how to make the 2nd line work? I'd greatly appreciate that!

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,257 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Kael Yao-MSFT 37,576 Reputation points Microsoft Vendor
    2021-08-25T05:57:47.727+00:00

    Hi @Bartosz Filipczak

    Please try this command and see if it works for you:

    $Inactive = Get-Mailbox -InactiveMailboxOnly -Filter "(LitigationHoldEnabled -eq 'false')"  
    $Inactive | foreach {Set-Mailbox -Identity $Inactive.DistinguishedName -ExcludeFromAllOrgHolds}  
    

    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.