Skip to content

Instantly share code, notes, and snippets.

@gscales
Last active February 19, 2021 05:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gscales/84e2d5fc0bb9cdccf634be84510c2f64 to your computer and use it in GitHub Desktop.
Save gscales/84e2d5fc0bb9cdccf634be84510c2f64 to your computer and use it in GitHub Desktop.
Get the TeamsMessagesDataFolder
$folderid= new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Inbox,$MailboxName)
$TeamsMessagesDataFolderEntryId = new-object Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition([System.Guid]::Parse("{E49D64DA-9F3B-41AC-9684-C6E01F30CDFA}"), "TeamsMessagesDataFolderEntryId", [Microsoft.Exchange.WebServices.Data.MapiPropertyType]::Binary);
$psPropset= new-object Microsoft.Exchange.WebServices.Data.PropertySet([Microsoft.Exchange.WebServices.Data.BasePropertySet]::FirstClassProperties)
$psPropset.Add($TeamsMessagesDataFolderEntryId)
$RootFolder = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($service,$folderid,$psPropset)
if ($RootFolder.TryGetProperty($TeamsMessagesDataFolderEntryId,[ref]$FolderIdVal))
{
$TeamsMessagesFolderId= new-object Microsoft.Exchange.WebServices.Data.FolderId((ConvertId -HexId ([System.BitConverter]::ToString($FolderIdVal).Replace("-","")) -service $service))
$TeamsMessagesDataFolder = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($service,$TeamsMessagesFolderId);
}
function ConvertId{
param (
[Parameter(Position=1, Mandatory=$false)] [String]$HexId,
[Parameter(Position=2, Mandatory=$false)] [Microsoft.Exchange.WebServices.Data.ExchangeService]$service
)
process{
$aiItem = New-Object Microsoft.Exchange.WebServices.Data.AlternateId
$aiItem.Mailbox = $MailboxName
$aiItem.UniqueId = $HexId
$aiItem.Format = [Microsoft.Exchange.WebServices.Data.IdFormat]::HexEntryId
$convertedId = $service.ConvertId($aiItem, [Microsoft.Exchange.WebServices.Data.IdFormat]::EwsId)
return $convertedId.UniqueId
}
}
@vagdevi17259
Copy link

The above code is not working for the Teams group mailboxes.
How to take the backup of the Teams Messages data stored in the Teams group mailboxes?

@gscales
Copy link
Author

gscales commented Feb 15, 2021

Can you access the mailbox with the EWSEditor (try Delegate Access you won't be able to impersonate)

@vagdevi17259
Copy link

I am new to the EWSEditor, can you share the exact steps please.
Unable to connect to the group mailbox using EWS Editor

@gscales
Copy link
Author

gscales commented Feb 18, 2021

You need to logon as a normal user that has been delegate access to the Group mailbox then right client and root folder choose the middle option and enter in the Email address from the Group mailbox

@vagdevi17259
Copy link

vagdevi17259 commented Feb 18, 2021

Thank you, it helped me a bit, but still not helping to get the actual functionality. With the above I am able to see the content of the folder "Top of Information Store". that doesn't have any TeamMessagesdata folder.
Unable to connect to the root folder.
The below error is coming, the logged on user has the delegate access to the group mailbox and also has compliance administrator and global administrator assigned.
suggest me if anything is missing w.r.t roles or permission.

BTW , the below is the error, when I am trying to expand the root tress structure
image

@gscales
Copy link
Author

gscales commented Feb 19, 2021

Did you try to add Full Permissions via add-mailboxpermission ? the other thing would be try to retrieve it via code instead it could just be a bug in that app

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment