How to put Teams Channel on eDiscovery Litigation hold?

Copper Contributor

I've been trying to work on a script that put Teams private and public channel on eDiscovery Litigation hold but not really sure how to proceed with my script so I would be really appreciated if I can get any help or suggestion on how to do that.


Basically the idea on how I'm trying to do is,I'll provide the Name of the channel at the top and it'll put the channel Mailbox and SharePoint on Hold with the assigned case.


$UserEmail = "Email address removed"

Get-Team -user $UserEmail

$Mailbox = Get-Mailbox | Where {$_.PrimarySmtpAddress -eq $UserEmail}

Get-UnifiedGroup | Where {(Get-UnifiedGroupLinks $_.Alias -LinkType Members).DistinguishedName -contains $mailbox.DistinguishedName}

Get-UnifiedGroup | select DisplayName, SharePointSiteUrl

Get-MailboxFolderStatistics -Identity "Office 365 Sandbox" -FolderScope ConversationHistory -IncludeOldestAndNewestItems | ?{$_.FolderType -eq "TeamChat"} | Format-Table Name, ItemsInFolder, NewestItemReceivedDate
Set-Mailbox -Identity "Office 365 Sandbox" -LitigationHoldEnabled $True -GroupMailbox


1 Reply

Hello @aasenomad ,

In your specific use case you need to enable Litigation hold in 3 different places:

  1. Group mailbox used for the team - to cover Team public channels
  2. 'Teams Chat' mailbox folder of private channel member - to cover Teams private channels
  3. SharePoint site used by the team - to cover file content

Based on the information mentioned above one of the possible approaches is:



#Enter Group Name
$TeamName="My Team"
#Get Team Group
$TeamGroup=Get-UnifiedGroup $TeamName
#Set Team mailbox on Litigation hold
Set-Mailbox -Identity $($TeamName.PrimarySMTPAddress) -LitigationHoldEnabled $true -GroupMailbox
#Get Teams Private Channels
$PrivateChannels=Get-TeamChannel -GroupId $($T.GroupId) | Where-Object {$_.MembershipType -eq "Private"}
#Get Private Channel members 
foreach($c in $PrivateChannnels){
    $Members=Get-TeamChannelUser -GroupId $($TeamGroup.GroupId) -DisplayName $($C.DisplayName)
    #Set at least one member's mailbox on Litigation Hold
    Set-Mailbox -Identity $($Members[0].User) -LitigationHoldEnabled $True
#Set Litigation Hold on Teams SharePoint Site 
New-CaseHoldPolicy -Name "Regulation $TeamName" -Case "$TeamName Files Compliance" -SharePointLocation $($TeamGroup.SharePointSiteUrl)



PowerShell modules used: ExchangeOnlineManagement, MicrosoftTeams.
In order to make it more elegant and effective you can also create on Hold Policy for SharePoint Site, Group Team and specific folder in private channels mailboxes.

Hope that helps.