Connect to Exchange Online Powershell
Connect-ExchangeOnline
Run the following Powershell script to get your list of FolderID
# Collect the target email address or SharePoint Url
# Authenticate with Exchange Online and the Microsoft Purview portal (Exchange Online Protection - EOP)
$addressOrSite = Read-Host "Enter an email address or a URL for a SharePoint or OneDrive for Business site"
if ($addressOrSite.IndexOf("@") -ige 0)
{
# List the folder Ids for the target mailbox
$emailAddress = $addressOrSite
# Connect to Exchange Online PowerShell
if (!$ExoSession)
{
Import-Module ExchangeOnlineManagement
Connect-ExchangeOnline -ShowBanner:$false -CommandName Get-MailboxFolderStatistics
}
$folderQueries = @()
$folderStatistics = Get-MailboxFolderStatistics $emailAddress
foreach ($folderStatistic in $folderStatistics)
{
$folderId = $folderStatistic.FolderId;
$folderPath = $folderStatistic.FolderPath;
$encoding= [System.Text.Encoding]::GetEncoding("us-ascii")
$nibbler= $encoding.GetBytes("0123456789ABCDEF");
$folderIdBytes = [Convert]::FromBase64String($folderId);
$indexIdBytes = New-Object byte[] 48;
$indexIdIdx=0;
$folderIdBytes | select -skip 23 -First 24 | %{$indexIdBytes[$indexIdIdx++]=$nibbler[$_ -shr 4];$indexIdBytes[$indexIdIdx++]=$nibbler[$_ -band 0xF]}
$folderQuery = "folderid:$($encoding.GetString($indexIdBytes))";
$folderStat = New-Object PSObject
Add-Member -InputObject $folderStat -MemberType NoteProperty -Name FolderPath -Value $folderPath
Add-Member -InputObject $folderStat -MemberType NoteProperty -Name FolderQuery -Value $folderQuery
$folderQueries += $folderStat
}
Write-Host "-----Exchange Folders-----"
$folderQueries |ft
}
References
Use Content search for targeted collections | Microsoft Learn
No responses yet