Solved

Search-Mailbox command to delete messages will not run using Powershell script

Posted on 2015-02-05
3
73 Views
Last Modified: 2015-03-10
Experts,

I have tried to run this script as directed by my research but it still gives me a " position parameter cannot be found that accepts argument ' -DeleteContent'

[PS] C:\Windows\system32>Search-Mailbox -Identity root-arl -SearchQuery "Received:<$(01/01/2015)", "From:(root@ARLCTXLOG
)" -DeleteContent -Force

I do not want to send these log file emails to another mailbox folder but get rid of them perm.

thanks!
0
Comment
Question by:JBfan
3 Comments
 
LVL 19

Expert Comment

by:Miguel Angel Perez Muñoz
Comment Utility
User running this command has delegated permissions on root-arl mailbox? Or you can add user running this command to Mailbox import export role: https://technet.microsoft.com/en-us/library/dd638205.aspx
0
 
LVL 24

Accepted Solution

by:
VB ITS earned 500 total points
Comment Utility
You will need to have the Mailbox Import Export management role assigned to your admin account first before you can use the -DeleteContent switch. By default this role isn't included in any of the built-in role groups in Exchange.

Run the below commands to first create the role group and assign it the Mailbox Import Export role, then add your admin account to this new role group:
New-RoleGroup "Mailbox Import Export Admins" -Roles "Mailbox Import Export"
Add-RoleGroupMember "Mailbox Import Export Admins" -Member "Your Admin Account"

Open in new window

Keep in mind that you can call the role group anything you like, it doesn't necessarily have to be named Mailbox Import Export Admins as outlined above.
0
 

Author Comment

by:JBfan
Comment Utility
Never got the email notification on this one.

thanks VB ITS!
0

Featured Post

Free book by J.Peter Bruzzese, Microsoft MVP

Are you using Office 365? Trying to set up email signatures but you’re struggling with transport rules and connectors? Let renowned Microsoft MVP J.Peter Bruzzese show you how in this exclusive e-book on Office 365 email signatures. Better yet, it’s free!

Join & Write a Comment

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
Learn to move / copy / export exchange contacts to iPhone without using any software. Also see the issues in configuration of exchange with iPhone to migrate contacts.
To show how to generate a certificate request in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.:  First we need to log into the Exchange Admin Center. Navigate to the Servers >> Certificates…
In this Micro Video tutorial you will learn the basics about Database Availability Groups and How to configure one using a live Exchange Server Environment. The video tutorial explains the basics of the Exchange server Database Availability grou…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now