Link to home
Start Free TrialLog in
Avatar of Leo
LeoFlag for Australia

asked on

Exchange 2010 PowerShell Command to Delete a single email database

Can anyone please assist me for an exchange powershell command, i want to delete a specific email address from a database from last week and onwards, means from that particular email address we want to delete it from a database anything we receive a week back.
we are running exchange 2010.
Avatar of Leo
Leo
Flag of Australia image

ASKER

and before running this command, is it possible that i would know how much space i will gain after deleting that particular email address from the database?
use the search-mailbox command:

http://technet.microsoft.com/en-us/library/dd298173.aspx

use it maybe with the sent sintax on the search query. something like this:

Search-Mailbox -Identity "April Stewart" -SearchQuery 'sent:19/10/2010' -DeleteContent

do it first without the -deletecontent to check the output and then add the delete content.
use the get-mailboxstatistics to check the space:

http://technet.microsoft.com/en-us/library/bb124612.aspx
Avatar of Leo

ASKER

can you please clear out to me how can i define dates, lets say i want to delete email from user@hotmail.com starting from last week upto 5 years back.
If you want to delete a mail sent from xpto@hotmail.com just dont use the date. use the from: parameter. like from:xpto@hotmail.com
I dont think that you can use a date range. what you have to do is to configure the filter with a syntax. the best way to test the syntax is to build the command without the -deletecontent and check the output. test and then when the output is what you want just add the deletecontent
Avatar of Leo

ASKER

i tested it couple of times, but it keeps thinking and doesnt generate an output report.
use a simplier command and check if you get an output. like:

Search-Mailbox -Identity "April Stewart" -SearchQuery 'sent:19/10/2010'
Avatar of Leo

ASKER

it came up with an error :-(

The target mailbox or .pst file path is required.
    + CategoryInfo          : InvalidArgument: (:) [], ArgumentException
    + FullyQualifiedErrorId : 72CC2AE3
ASKER CERTIFIED SOLUTION
Avatar of Antonio Vargas
Antonio Vargas
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial