Solved

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

Posted on 2015-02-05
3
78 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
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:JBfan
ID: 40657550
Never got the email notification on this one.

thanks VB ITS!
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Utilizing an array to gracefully append to a list of EmailAddresses
Find out what you should include to make the best professional email signature for your organization.
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…
This video discusses moving either the default database or any database to a new volume.

911 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

20 Experts available now in Live!

Get 1:1 Help Now