Last active
February 19, 2021 05:54
-
-
Save gscales/84e2d5fc0bb9cdccf634be84510c2f64 to your computer and use it in GitHub Desktop.
Get the TeamsMessagesDataFolder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $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 | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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