I'm trying to create a script that will delete the content of a specific SubFolder from a specific Mailbox using powershell (EWS is NOT an option at this point)
I came up with the following script:
Get-Mailbox -Identity "firstname.lastname@example.org" |Search-Mailbox -TargetFolder "Inbox\Bla\Blu\test" -T
argetMailbox "email@example.com" -DeleteContent -Force
While it does delete the content of the required folder, it also deletes the content of the containing folders (The content of the entire Tree was deleted)!
Obviously this isn't good for us.
I also tried the script with the exact name without the entire tree :
Get-Mailbox -Identity "firstname.lastname@example.org" |Search-Mailbox -TargetFolder "test" -T
argetMailbox "email@example.com" -DeleteContent -Force
With the same results.