Solved

PowerShell for Exchange

Posted on 2014-01-20
7
749 Views
Last Modified: 2014-01-26
Need to remove a particular message from all users in the current database. Currently, we are doing this one by one. Is it possible to modify the below script to automate this process, by importing a csv file with all the email that need to remove a particular message ? Tks


Search-Mailbox -Identity "jo.leung" -SearchQuery 'Subject:Backup Exec Alert and received:12/25/2014' –DeleteContent
0
Comment
Question by:AXISHK
[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
  • 2
7 Comments
 
LVL 25

Assisted Solution

by:Zephyr ICT
Zephyr ICT earned 250 total points
ID: 39796197
What's the Exchange version?

Does something like this not give the wanted result?

get-mailbox -resultsize unlimited | Search-Mailbox -SearchQuery 'Subject:Backup Exec Alert and received:12/25/2014' –DeleteContent
0
 

Author Comment

by:AXISHK
ID: 39796276
Is it possible to limited the searching within a special time range ?

Tks
0
 
LVL 70

Accepted Solution

by:
Qlemo earned 250 total points
ID: 39796967
I take it you definitive do NOT want to delete the content of all mailboxes, only for specific ones contained in the CSV.
get-content C:\Temp\Mailboxes.txt | Search-Mailbox -Identity $_ -SearchQuery 'Subject:Backup Exec Alert AND received:>12/25/2013 AND received:<1/1/2014' –DeleteContent -WhatIf

Open in new window

0
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 

Author Comment

by:AXISHK
ID: 39798910
Doesn't work. Any idea ?

[PS] C:\Windows\system32>Search-Mailbox -Identity "John.leung" -SearchQuery "received:>01/21/2014 AND received:<01/2
2/2014" –Logonly –Targetmailbox buadmin –Targetfolder Inbox
Try using fewer keywords at the same time, reducing the number of users in the From, To, Cc, and Bcc fields, and reduci
ng the number of mailboxes that are searched at the same time. When you use wildcards, make search queries as specific
as possible. For example, if the search query used short words with one or more wildcards (for example, pat*), a large
number of words or phrases may be returned because all words that start with "pat" are searched. Search failed on mailb
ox 'abc\John M H Leung\682601b5-50f9-458d-a7da-d6dd62f4470c'.
    + CategoryInfo          : ReadError: (0:Int32) [Search-Mailbox], SearchMailboxException
    + FullyQualifiedErrorId : BB69DE3C,Microsoft.Exchange.Management.Tasks.SearchMailbox



RunspaceId       : f1d4a044-6eea-4bd2-a6f3-35e68abb652f
Identity         : abc.com.hk/HK//John Leung
DisplayName      : John Leung
TargetMailbox    : abc.com.hk/SERVERS/HK/Users/BUadmin
TargetPSTFile    :
Success          : False
TargetFolder     : \Inbox\
ResultItemsCount : 0
ResultItemsSize  : 0 B (0 bytes)
0
 
LVL 70

Expert Comment

by:Qlemo
ID: 39799324
No idea, since that works for me without error (but without result either - cannot test that far).
0
 

Author Closing Comment

by:AXISHK
ID: 39810866
The following powershell works for me, thanks for the information.

Search-Mailbox -Identity "John.lo" -SearchQuery {received:01/24/2014 9:00 ..01/24/2014 10:00}  –Logonly –Targetmailbox itadmin –Targetfolder Inbox
0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

Lotus Notes – formerly IBM Notes – is an email client application, while IBM Domino (earlier Lotus Domino) is an email server. The client possesses a set of features that are even more advanced as compared to that of Outlook. Likewise, IBM Domino is…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In this video we show how to create an Accepted Domain 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 >> Ac…
This video discusses moving either the default database or any database to a new volume.
Suggested Courses
Course of the Month6 days, 19 hours left to enroll

622 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