Skip to content

Instantly share code, notes, and snippets.

@evenevan
Last active September 6, 2024 06:23
Show Gist options
  • Save evenevan/ca4e79fe3f346dc86599d9d53daa35de to your computer and use it in GitHub Desktop.
Save evenevan/ca4e79fe3f346dc86599d9d53daa35de to your computer and use it in GitHub Desktop.
Export Microsoft Teams chats with a work or school account
@evenevan
Copy link
Author

I really appreciate your involvement with this project - thank you so much :)

Based on the permissions you've shown me, I found that the traditional scope type should be valid, as none require admin permissions, and for some reason, I hadn't thought of trying it out with the PnP Management Shell application. I've given this a quick test, and it seems to work. In theory, using the PnP Management Shell (which appears to be an allowed app for your org) and the traditional scopes (which allow fine-tuned control over the permissions) should get you through every hoop.

I've pushed another change to the project, which removes the OpenID scope type. Downloading the new code and following the normal guide should hopefully work, if you decide to continue to pursue this of course.

Finally, that error in the last message you sent is somewhat interesting, as it says that it missing a scope. If you hit consent on the Chat.Read permission, that'll probably work.

@anlyx
Copy link

anlyx commented Sep 3, 2023

Hi!
thanks for your work.
I want to report you that each chat with square brackets [ ] fail to export:

image

easy to fix, just add after line 156 :
$name = $name -replace '[[]]','_'

result:
image

Bye :)

@anlyx
Copy link

anlyx commented Sep 3, 2023

Is there a way to also embed in the chat all sent and received files ?
right now in the exported html there is just the link to sharepoint.

@evenevan
Copy link
Author

evenevan commented Sep 3, 2023

Hi! thanks for your work. I want to report you that each chat with square brackets [ ] fail to export:

image

easy to fix, just add after line 156 : $name = $name -replace '[[]]','_'

result: image

Bye :)

Hey! Thanks for the fix, but I've pushed a slightly different fix for your issue that preserves the square brackets; the issue was an oversight on wildcard paths and just required changing parameters.

Is there a way to also embed in the chat all sent and received files ? right now in the exported html there is just the link to sharepoint.

I've glanced through the process of downloading SharePoint files and I have concluded that for the time being, I don't have the time to try and make it work.

If you're up for it, you could open an an issue/pull request and work on an implementation. Otherwise, I may try adding this later on once I get some time. Although far from ideal, another solution is simply having all of the files available separately (you should have a folder name "Microsoft Teams Chat Files" in your org's OneDrive that has your uploaded files, but do note this doesn't include files uploaded by others).

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