Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Received in "Search-Mailbox - SearchQuery" issue (Exchange 2013)

Posted on 2016-11-03
2
Medium Priority
?
126 Views
Last Modified: 2016-11-04
This does not work because of "Receive"

$today=(get-date).adddays(-30)
$data = import-csv C:\NB\Emails\users.csv

foreach ($i in $data)

  { $alias = $i.mailbox;

    Search-Mailbox -id $alias -SearchQuery 'From:"Someone@verizon.net" AND Received:<$($today)' -DeleteContent
}

It work if I put a specific date - Received>=10/31/201

what am I doing wrong?
0
Comment
Question by:nourben
[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
2 Comments
 
LVL 8

Accepted Solution

by:
CodeTwo Software earned 2000 total points
ID: 41873729
Hi nourben,

The problem might be the date format - have you tried (get-date).adddays(-30).tostring(MM/dd/yyyy)?

- CodeTwo
1
 

Author Comment

by:nourben
ID: 41874214
Thanks, it worked with a minor change (get-date).adddays(-30)tostring('MM/dd/yyyy')

I also had to change: Received<$today
1

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

A couple of months ago we ran into an issue that necessitated re-creating our Edge Subscriptions. However, when we attempted to execute the command: New-EdgeSubscription -filename C:\NewEdgeSub_01.xml we received an error indicating that the LDAP se…
I don't pretend to be an expert at this, but I have found a few things that are useful. I hope that sharing them here will help others, so they will not have to face some rather hard choices. Since I felt this to be a topic of enough importance and…
In this video we show how to create an email address policy 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…
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…
Suggested Courses

715 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