Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 191
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

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