Solved

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

Posted on 2015-02-05
3
88 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:Russ Wrightson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 19

Expert Comment

by:Miguel Angel Perez Muñoz
ID: 40593096
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
ID: 40593289
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:Russ Wrightson
ID: 40657550
Never got the email notification on this one.

thanks VB ITS!
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
Read this checklist to learn more about the 15 things you should never include in an email signature.
To show how to create a transport rule 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 Mail Flow >> Rules tab.:  To cr…
how to add IIS SMTP to handle application/Scanner relays into office 365.

738 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