Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Thursday, November 28, 2019 6:22 AM
Hello,
how to get office 365 exchange mailbox folders ID in powershell command ?
All replies (8)
Thursday, November 28, 2019 8:14 AM | 3 votes
Hi Tommy,
You can do it using the Get-MailboxFolderStatistics cmdlet:
Get-MailboxFolderStatistics -Identity [email protected] | select Name, FolderId, FolderPath
Don't forget to change the Identity ([email protected]) to the corresponding user's identity.
If you need to get the folder ID converted to the proper format to use it in eDiscovery searches or such, then you can use the simple script below:
$mbx = "[email protected]"
$mbxStatistics = Get-MailboxFolderStatistics -Identity $mbx
$folderQueries = @()
foreach ($stat in $mbxStatistics){
$folderName = $stat.Name
$folderId = $stat.FolderId;
$folderPath = $stat.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]}
$folderIdConverted = $($encoding.GetString($indexIdBytes))
$folderDetails = New-Object PSObject
Add-Member -InputObject $folderDetails -MemberType NoteProperty -Name FolderName -Value $folderName
Add-Member -InputObject $folderDetails -MemberType NoteProperty -Name FolderId -Value $folderIdConverted
Add-Member -InputObject $folderDetails -MemberType NoteProperty -Name FolderPath -Value $FolderPath
$folderQueries += $folderDetails
}
$folderQueries
Again, don't forget to update $mbx variable in this one, too.
Regards,
Burak V.
Thursday, November 28, 2019 1:26 PM
Thanks , for the answer. I was thinking folderID would be the same as LastParentFolderID , but I was wrong.
How to get LastParentFolderID ?
Thursday, November 28, 2019 1:35 PM | 2 votes
Thanks , for the answer. I was thinking folderID would be the same as LastParentFolderID , but I was wrong.
How to get LastParentFolderID ?
The LastParentFolderID parameter specifies the FolderID value of an item before it was deleted. So, talking about a deleted/recoverable item, its LastParentFolderID is the same as the corresponding folder's FolderID.
Thursday, November 28, 2019 2:42 PM
Get-MailboxFolderStatistics -Identity [email protected] | select Name, FolderId, FolderPath
When using command Get-RecoverableItems I get another FolderID
Get-RecoverableItems -Identity "[email protected]" -FilterItemType IPM.Note -FilterStartTime "11/04/2019 08:00:00 AM" -FilterEndTime "11/27/2019 17:01:59 PM"
Thursday, November 28, 2019 5:29 PM | 2 votes
Get-MailboxFolderStatistics -Identity [email protected] | select Name, FolderId, FolderPath
When using command Get-RecoverableItems I get another FolderID
Get-RecoverableItems -Identity "[email protected]" -FilterItemType IPM.Note -FilterStartTime "11/04/2019 08:00:00 AM" -FilterEndTime "11/27/2019 17:01:59 PM"
Actually that's why I've also provided a script in addition to that cmdlet in my first reply. You'll need to get the FolderID value converted to the same format as in the LastParentFolderID using that script. Just update the $mbx variable and run it right away.
Friday, November 29, 2019 6:57 AM
Thanks
Monday, December 2, 2019 1:13 AM
Hi,
I'm here to confirm with you if your issue has been resolved. If the problem is successfully solved, you can mark the helpful reply as answer, this will make answer searching in the forum easier and be beneficial to other community members as well.
Thanks for your understanding.
Regards,
Joyce Shen
Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact [email protected].
Friday, December 6, 2019 10:04 AM
A brief summary of this post so that other forum members could easily find useful information here:
[Office 365 folder id - summary]
Issue Symptom:
How to get office 365 exchange mailbox folders ID in powershell command ?
Solution:
Get-MailboxFolderStatistics -Identity [email protected] | select Name, FolderId, FolderPath
If you need to get the folder ID converted to the proper format to use it in eDiscovery searches or such, then you can use the simple script below:
$mbx = "[email protected]"
$mbxStatistics = Get-MailboxFolderStatistics -Identity $mbx
$folderQueries = @()
foreach ($stat in $mbxStatistics){
$folderName = $stat.Name
$folderId = $stat.FolderId;
$folderPath = $stat.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]}
$folderIdConverted = $($encoding.GetString($indexIdBytes))
$folderDetails = New-Object PSObject
Add-Member -InputObject $folderDetails -MemberType NoteProperty -Name FolderName -Value $folderName
Add-Member -InputObject $folderDetails -MemberType NoteProperty -Name FolderId -Value $folderIdConverted
Add-Member -InputObject $folderDetails -MemberType NoteProperty -Name FolderPath -Value $FolderPath
$folderQueries += $folderDetails
}
$folderQueries