Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 144
  • Last Modified:

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

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
nourben
Asked:
nourben
1 Solution
 
CodeTwo SoftwareSoftware DeveloperCommented:
Hi nourben,

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

- CodeTwo
1
 
nourbenAuthor Commented:
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

Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now