I have a shared mailbox with a lot of emails. I need to move all these emails to a teams email group. I'm hoping there's something simple I'm missing. I'm open to using other languages if existing solutions/libraries exist for them.
I have been attempting to use powershell to automate this process. I have so far been unsuccessful. I'm not sure if this is even possible the way I want it to be done. I've attempted to use some commands. Everything I try is either deprecated or does not work, and I'm not sure why. I've looked into Power Automate but as far as I can tell that wont let me actually transfer the emails to the team groups inbox.
Emails = Get-EXOMailbox -Identity $SharedMailbox | Get-MailboxFolderStatistics | Where-Object {$_.FolderType -eq "Inbox"} | Get-MailboxFolder | Get-Message
# Move emails to the Teams group email
foreach ($Email in $Emails) {
$Email | Move-Message -Destination $TeamsGroupEmail
}