Anybody use the New-Mailbox cmdlet

I have a script to clean out mailbox(s) that currently use the search-mailbox cmdlet and it works for most cases. But I have one mailbox (mail journal) that houses a copy of all emails coming and going and once a month after backing it up I delete the content that's older than 1 month. Search-Mailbox works for the fist 10000 but progressively returns less and less items even though there are usually still about 20000 + emails that need to be deleted. I've been looking at the New-MailboxSearch cmdlet but I don't see any way to delete content. Anybody overcome this issue?

Thanks Richard
RichardPWolfAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jian An LimSolutions ArchitectCommented:
0
RichardPWolfAuthor Commented:
As I mentioned that's currently what I use but..... let's say I have 30000 messages to delete. First run will delete 10000, second run maybe 5000, third run maybe 10 and after that 0. But when I go into the mailbox there's still 14990 messages that need to be deleted. This happened sporadically when we were on Exchange 2010 but happens all the time now that we're on 2013.
0
Jian An LimSolutions ArchitectCommented:
my understanding, there are no other powershell to delete content except this command.

Unless, you want to login as this user and use outlook OR use archiving method to move them out from the mailbox to archived mailbox then delete.

https://technet.microsoft.com/en-us/library/aa996035%28v=exchg.141%29.aspx?f=255&MSPPError=-2147217396
0
How the Cloud Can Help You as an MSSP

Today, every Managed Security Service Provider (MSSP) needs a platform to deliver effective and efficient security-as-a-service to their customers. Scale, elasticity and profitability are a few of the many features that a Cloud platform offers. Register today to learn more!

yo_beeDirector of Information TechnologyCommented:
Could you run this using Outlook?
I used this method back when I had exchange 2003 and all my journaling was done on my system. We have since moved to a hosted spam filter and archiving so this task has become a thing of past.
0
dan_blagutCommented:
Hello

there are another question on the site with same object:
http://www.experts-exchange.com/Software/Server_Software/Email_Servers/Exchange/Q_28296589.html
can you look at the code examples?

Dan
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RichardPWolfAuthor Commented:
limjianan, yo_bee - Currently that's how I'm doing it but the whole idea is to automate it as I have enough on my plate without logging in as the mail journaling to use outlook on another system. This take a lot of time away from other duties I have.
dan_blagut - His code is very similar to mine. Here's mine;
#*=============================================
 #* Remove Previous Months emails from MJournal
 #*=============================================
 Write-Host "Removing Old Entries from MJournal" -foreground "green"
 Write-Verbose "If all good to this point delete old email using $edate"
      Get-Mailbox -Identity "Mail Journal" | Search-Mailbox -SearchQuery {(Received -le '$edate')} -DeleteContent -force
0
Jian An LimSolutions ArchitectCommented:
yes, i agreed. as a result, my recommendation is to use managed folder mailbox policy.

In theory, the script should run well. there are some thing we don't have a clear picture of that causing the email.


understand the managed folder mailbox policy
https://technet.microsoft.com/en-us/library/ee364744%28v=exchg.141%29.aspx

other instruction
https://technet.microsoft.com/en-us/library/aa996035%28v=exchg.141%29.aspx
0
RichardPWolfAuthor Commented:
limjianan - I don't see where managed mailboxes are relevant to my question. This isn't about how the users manage there emails but maintenance on a single mailbox that holds a copy of all emails and at the end of the month gets backed up and stored. Just to clarify I'm anal about backups and hold at least two types to insure that I can comply with e-discovery and other regulatory requirements.
0
Jian An LimSolutions ArchitectCommented:
you can use managed mailbox and apply to this particular mailbox, then use this tool to remove the emails accordingly.
This is just one of a creative way to solve an issue that normally a command should run.

if not, there will be alternative way is to create a new mailbox because I suggest the mailbox might in issue.
Make a routine to change to a new journal mailbox every month to avoid these kind of issues.

Fundamentally, there are something missing in the pictures that I am just putting our 2 cents  :)
0
RichardPWolfAuthor Commented:
I see now where you're going with the managed mailbox but I don't understand how that is going to mitigate the problem with deleting more than 10000 emails at a time or that it seems that it doesn't see the total remaining emails when the script runs. Could it be a sync issue with the mailbox and the exchange in that it takes time for the exchange to actually delete the emails and get new totals?
0
Jian An LimSolutions ArchitectCommented:
It could be anything as i originally said.
it could be your health of your mailbox database.
it could be indexing issue.
it could be the system don't like -SearchQuery {(Received -le '$edate')} ONLY, you might need to use -SearchQuery {(Received -le '$edate') -and (Received -ge '$edate'} to limit your search result.

we can keep on technically finding the issues.
Or we can solve it by create a new mailbox and see how it goes.

Just one of the options :)
0
RichardPWolfAuthor Commented:
OK,
Yes it could be anything and that's what I'm trying to find out. I know I'm not the only one having this problem from what I'm seeing on the internet.

Checked health this morning and it looks good.
Indexing??????? hmmmm I'll check that out and re-index if possible (offline defrag?).
Search Query needing both a start date and end date, hmmmmmm I'll try that.
Create new mailbox. Possible. I can try that to eliminate that part of the equation but it will be another month before I can see results. This is because of the extra backup I do and the procedures we have in place.

I'll let you know the results as they happen.
0
RichardPWolfAuthor Commented:
At this point I haven't found a way that meets with my expectations. At this point I've got some other creative ideas and if they work I'll post the results.

thanks to all that have contributed. Not sure how to spread the points.
0
RichardPWolfAuthor Commented:
There appears not to be a really good resolution. Dan's script is what I'm currently using but it fails to get all emails and the new cmdlet doesn't allow for deleting. So my only option is to open the mailbox in question with a cached Outlook setup and manually delete the emails. Painfully slow but it's the only way to do it at this time. Closing this question as unresolved and to cleanup my question pools.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.