deleting old mail from users db exchange 2016. what is the right command from powershell?

%3CLINGO-SUB%20id%3D%22lingo-sub-1342908%22%20slang%3D%22en-US%22%3Edeleting%20old%20mail%20from%20users%20db%20exchange%202016.%20what%20is%20the%20right%20command%20from%20powershell%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1342908%22%20slang%3D%22en-US%22%3E%3CP%3EGood%20morning%2C%3CBR%20%2F%3Ein%20these%20days%20I%20am%20archiving%2Fstoring%20the%20old%20mail%20on%20the%20exchange%20server%202016%20of%20mailboxes%20until%2001%2F01%2F2019%2C%20once%20the%20mailboxes%20have%20been%20exported%20to%20.pst%20I%20delete%20the%20mails%20with%20the%20following%20command%3A%3CBR%20%2F%3E%3CFONT%20color%3D%22%230000FF%22%3E%3CEM%3ESearch-Mailbox%20-Identity%20mailbox%20-SearchQuery%20'Received%20%26lt%3B01%2F01%2F2019'%20-DeleteContent%20-Force%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3EI%20found%2C%20however%2C%20that%20with%20this%20command%20all%20the%20additional%20information%20of%20the%20mailbox%20are%20deleted%20as%20well%20as%20the%20mails%20also%20contacts%20%26lt%3B01%2F01%2F2019%20calendars%2C%20notes%2C%20etc.%2C%20the%20verification%20I%20did%20with%20the%20following%20command%3CBR%20%2F%3E%3CEM%3E%3CFONT%20color%3D%22%230000FF%22%3ESearch-Mailbox%20-Identity%20mailbox%20-SearchQuery%20'Received%20%26lt%3B01%2F01%2F2019'%20-LogOnly%20-LogLevel%20full%20-TargetMailbox%20(mailboxname)%20-TargetFolder%20search%3C%2FFONT%3E%3C%2FEM%3E%3CBR%20%2F%3Eso%20I%20used%20the%20following%20command%20to%20delete%20only%20the%20emails%3A%3CBR%20%2F%3E%3CEM%3E%3CFONT%20color%3D%22%230000FF%22%3ESearch-Mailbox%20-Identity%20mailbox%20-SearchQuery%20%7B(kind%3A%20Email)%20-lt%20'Received%20%26lt%3B01%2F01%2F2019'%7D%20-DeleteContent%20-force%3C%2FFONT%3E%3C%2FEM%3E%3CBR%20%2F%3Ealso%20launching%20a%20log%20on%20the%20command%2C%20however%2C%20some%20old%20emails%20prior%20to%2001%2F01%2F2019%20remain%20and%20I%20can%20not%20delete%20them%20except%20by%20hand.%3CBR%20%2F%3Ewhat%20am%20i%20doing%20wrong%20in%20the%20command%20kind%3A%20email%3F%3CBR%20%2F%3Ecan%20you%20give%20me%20the%20precise%20command%20to%20delete%20only%20the%20emails%20and%20not%20all%20the%20rest%3F%3CBR%20%2F%3EI%20have%20been%20trying%20to%20find%20the%20precise%20command%20for%202%20weeks%20now%20but%20I%20can't%2C%20can%20you%20help%20me%20out%3F%3CBR%20%2F%3ETHANK%20YOU%20VERY%20MUCH%3CBR%20%2F%3EYours%20sincerely%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1342908%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExchange%20Server%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
New Contributor

Good morning,
in these days I am archiving/storing the old mail on the exchange server 2016 of mailboxes until 01/01/2019, once the mailboxes have been exported to .pst I delete the mails with the following command:
Search-Mailbox -Identity mailbox -SearchQuery 'Received <01/01/2019' -DeleteContent -Force
I found, however, that with this command all the additional information of the mailbox are deleted as well as the mails also contacts <01/01/2019 calendars, notes, etc., the verification I did with the following command
Search-Mailbox -Identity mailbox -SearchQuery 'Received <01/01/2019' -LogOnly -LogLevel full -TargetMailbox (mailboxname) -TargetFolder search
so I used the following command to delete only the emails:
Search-Mailbox -Identity mailbox -SearchQuery {(kind: Email) -lt 'Received <01/01/2019'} -DeleteContent -force
also launching a log on the command, however, some old emails prior to 01/01/2019 remain and I can not delete them except by hand.
what am i doing wrong in the command kind: email?
can you give me the precise command to delete only the emails and not all the rest?
I have been trying to find the precise command for 2 weeks now but I can't, can you help me out?
THANK YOU VERY MUCH
Yours sincerely

0 Replies