UPN change - file links in one to one and in group chats wrong-How to update them powershell,graph?

Copper Contributor

Hi Experts


Maybe wrong place to post? 

We are in a process of changing all UPN´s to match primary mail address. This includes changing both prefix and suffix.


While doing this we now found out that this causes the file links in Teams chats one to one and group chats (not chats in channels) to need updated to the new UPN´s.

I am a bit disappointed that this does not update itself.

I have tried to find somehow I can get all chat messages from specific user and then loop through them to first of get to know which and how many links needs updated, but I cannot find a way to get this information. I have tried to find a way via Microsoft Graph powershell. Please point me in the correct direction. Do I need to connect with app that have the right API permissions or "just" a global admin account? I can do both, but I have failed so far to find out how to retrieve all chat messages and then go through them.

All help VERY much appreciated!

5 Replies
First, you should have done this before you migrated. As you can see afterwards can cause issues.
Are you syncing accounts with AADConnect? If changing on premises you may be breaking the sync

@Ed Woodrick What should have been done before? UPN was not possible to change when we started the cloud journey. No need for me to explain that is just a fact for us.


We are not breaking any sync.


My question is only if anyone can help me point me in the correct direction to Graph (prefer via graph powershell module) script or just cmdlets that can be used to find all links in all one on one chats, group chats and meeting chats that contains links with old UPN´s. This however seems from my investigation so far not to be easy at all. Also it might include using metered API´s that needs first to be approved to use by MS (once a week they approve) and also have usage costs. :-(.



Did you ever find a way to do this? We are running into a similar situation and need to update a bunch of Teams links.
No. Only one user contacted us and we decided not to use more time on it. The workaround: User copy the link and modify it to reflect the new UPN.