Feb 16 2022 09:01 AM - edited Feb 16 2022 10:27 AM
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"
Connect-MicrosoftTeams
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
```
Feb 20 2022 09:20 AM - edited Feb 20 2022 09:23 AM
Hello @aasenomad ,
In your specific use case you need to enable Litigation hold in 3 different places:
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.