Remove litigation hold using PowerShell

Barry Hart 20 Reputation points

Hi, I am trying the delete litigation hold from several thousand Office 365 accounts. I have a .csv that only has one column and it contains the email addresses of those that I want to remove litigation hold from. I was trying to use this script Connect-ExchangeOnline
$csv=Import-CSV -Path "C:\Litcsv.csv"
ForEach ($user in $csv)
Set-Mailbox $user | Where-Object { $_.LitigationHoldEnabled -eq $True } |Set-Mailbox -LitigationHoldEnabled $False
} However I am getting this error:
User's image

Any help is appreciated. Thanks in advance.

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,053 questions
{count} votes

Accepted answer
  1. Vasil Michev 91,046 Reputation points MVP

    The first cmdlet should be Get-Mailbox, not Set-Mailbox

    Get-Mailbox $user | Where-Object { $_.LitigationHoldEnabled -eq $True } |Set-Mailbox -LitigationHoldEnabled $False
    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful