This will be related to Exchange online, I didn't know where else to put this, but the powershell for this question I think will be the same.
I had a problem in a remote move migration to exchange online in which both a cloud version and on-prem version of the mailbox existed and was working. the cloud version had all the data, the on-prem mailbox was empty.
we worked on it for several hours then decided to delete the cloud mailbox and re-migrate the on-prem mailbox.
we ran an in-place hold and then downloaded the pst file directly from the web console, but did not copy it to the discovery mailbox first so no folder structure was recreated. After deleting the user object from office 365 and removing the user from recycle bin, the mailbox still persisted with some new errors in the web console I had not seen before and would not delete until we deleted the inplace hold - so now all we have is this pst which has no folder structure in it.
I restore the pst back after successfully migrating and discover the missing folder structure.
With the pst file downloaded a csv file which listed lots of metadata about every object in the pst including the original folder it came from. I thought that if I could find a common unique attribute which I could use against what was in the mailbox, I could place each object back into a new folder named the same thing as the folder whence it came. The closest thing I could find to unique was the received time, which after deleting all of the damn calendar holidays, there were only 12 non-unique values out of ~3500 objects.
search-mailbox cannot have the same mailbox be the source and target, so I thought to copy it to another where I could pst transport it back over. Instead what I get - which is expected admittedly, is a folder named what I specified in -targetfolder then a child folder named "username-date" then a subfolder named "primary mailbox" then another subfolder "inbox" since inbox is the folder all of the emails are in currently.
I don't know of any other way to manipulate objects inside a mailbox. I have the unique attribute I can use to put into a csv file for each folder the message was supposed to be in. I have the folders all of the messages are supposed to be in associated to the unique attribute. I'm just not sure how to move these - if there even is a way.
does anyone have any ideas?