Search-Mailbox -SearchQuery not filtering time correctly

After reading: http://technet.microsoft.com/en-us/library/dd298173(v=exchg.150).aspx
which links off to: http://msdn.microsoft.com/library/ee558911%28v=office.15%29.aspx
I made the following PowerShell script for testing before I start deleting anything:
$A=Get-Date '18/7/2014'
$Start=Get-Date $A.ToUniversalTime() -Format yyyy-MM-ddThh:mm:ss
$End=Get-Date $A.AddDays(1).ToUniversalTime() -Format yyyy-MM-ddThh:mm:ss
$SearchQuery='Received>="'+$Start+'" AND Received<"'+$End+'"'
Search-Mailbox -Identity 'mailbox@domain' -SearchQuery $SearchQuery -TargetMailbox 'targetmailbox@domain' -TargetFolder Inbox -LogOnly -LogLevel Full
The results I get back are all the emails between 17/7/2014 12:00 AM - 18/7/2014 12:00 AM
When I thought it should be the emails between 17/7/2014 2:30 PM - 18/7/2014 2:30 PM (Our time zone is +9:30)
Does the query I'm passing to -SearchQuery need tweaking or am I doing something else wrong?
The $SearchQuery variable expands out to this:
Received>="2014-07-17T02:30:00" AND Received<"2014-07-18T02:30:00"
I'm using the Search-Mailbox cmdlet because is wish to adjust this script to use the -DeleteContent paramater

Hi,
I recommend you post this in
Powershell Forum also, as they should have more professional knowledge on scripting and you may get effective solution timely.
Thanks.
Niko Cheng
TechNet Community Support

Similar Messages

  • IPad not keeping time correctly

    Last night I noticed my iPad is not keeping time. It said 9:40 at 10:30pm. I checked the settings and it didn't correct itself. It's still off today. Anyone else have this problem? I don't want to manually set the time. I read on another board that Apple was replacing iPads with this problem.

    This happened to me a couple of days ago when I charged my ipad with the adaptor and did not synch with my imac. After synching with my Mac the time was corrected but after a day the clock 'drifted' again. I reported fault to Apple and they suggested a reset using 'Settings'. Did as instructed and so far OK. I am no 'expert' in these matters but not synchronising for a couple of days seems to cause a problem. Apple should be aware of this and I have sent a comment back to them

  • Problem with waveform chart: time scale does not show time correctly

    Hello,
    I have some problems with a chart.
    I want to display some data and the time between two single data can vary. It is something between 50ms and 500 ms.
    The problems I have:
    1. The time is not shown correctly in the chart (allways 2:00:10 instead of the current time)
    2. the data points in the chart have a distance of 1 s (x-scale). That is not correct.
    I have tried several things but I thinkt I am on the wrong track.
    Could you please help me?
    Johannes
    LabVIEW 7.1 (!)
    Message Edited by johanneshoer on 10-14-2009 04:26 AM
    Greetings Johannes
    Using LabVIEW 7.1 and 2009 recently
    Solved!
    Go to Solution.
    Attachments:
    Chart Test.vi ‏55 KB

    I have modifierd the vi again.
    Now it looks much better.
    I have a data array and the last 10 seconds of the data are displayed.
    The array size is maximum 150 and that is more than I need to display. If new data is inserted, the oldest gets deleted.
    I wonder if this style is efficient?
    The time is stil not displayed correctly in the graph. Why does it always show 2:00:00 ?
    Johanens
    LabVIEW 7.1
    Greetings Johannes
    Using LabVIEW 7.1 and 2009 recently
    Attachments:
    Chart Test 3.vi ‏57 KB

  • Intel iMac not reading time correctly

    G'day
    This is pretty desperate. I've got a 3000+ line applescript that automates a mail room for a large company.
    They want to buy an intel iMac to exclusively run the script, but the script uses time based files for error reporting.
    On my intel iMac the files read as 1st January 1904 12.00.00 am not matter what I do.
    Are Apple fixing this, or is there a workaround?
    Regards, Santa

    Thanks red_menace. The test script I ended up with is as follows...
    my Timer()
    my displayInfo()
    on Timer()
    copy (current date) - (time to GMT) to tempDate
    -- For universal time
    copy tempDate to KeepTheTime
    -- For an invisible file, put a full stop in front of the name ie ".Timer"
    set t to my ReadTheTime("Timer", KeepTheTime)
    display dialog "elapsed : " & my setTheDaysHoursMinutesSeconds(KeepTheTime - t) buttons {"OK", "See elapsed time", "Reset Timer"}
    set temp to button returned of the result
    if temp = "Reset Timer" then
    copy (current date) - (time to GMT) to tempDate -- For universal time
    my SaveTheTime("Timer", tempDate)
    my Timer()
    else
    if temp = "See elapsed time" then my Timer()
    end if
    end Timer
    on displayInfo()
    copy (current date) - (time to GMT) to tempDate -- For universal time
    copy tempDate to KeepTheTime
    set time of tempDate to 0
    set dayelapsedtime to KeepTheTime - tempDate
    set day of tempDate to 1
    set monthelapsedtime to KeepTheTime - tempDate
    set month of tempDate to 1
    set yearlyelapsedtime to KeepTheTime - tempDate
    display dialog "Universal time" & return & return & ¬
    "Since midnight, " & dayelapsedtime & " seconds have elapsed." & return & my setTheDaysHoursMinutesSeconds(dayelapsedtime) & return & return & ¬
    "Since 12.00 am on the first of the month, " & monthelapsedtime & " seconds have elapsed." & return & my setTheDaysHoursMinutesSeconds(monthelapsedtime) & return & return & ¬
    "Since 12.00 am January 1, " & yearlyelapsedtime & " seconds have elapsed." & return & my setTheDaysHoursMinutesSeconds(yearlyelapsedtime) buttons {"OK", "Refresh information"}
    if button returned of the result = "Refresh information" then my displayInfo()
    end displayInfo
    on ReadTheTime(Filename, KeepTheTime)
    tell application "Finder"
    set TheFileName to (path to desktop folder as string) & Filename
    try
    set theSavedTime to (read file TheFileName as «class isot») as date
    return theSavedTime
    on error
    my SaveTheTime(Filename, KeepTheTime)
    return KeepTheTime
    end try
    end tell
    end ReadTheTime
    on SaveTheTime(Filename, KeepTheTime)
    tell application "Finder"
    set TheFileName to (path to desktop folder as string) & Filename
    end tell
    set fRef to (open for access file TheFileName with write permission)
    set eof fRef to 0
    try
    set KeepTheTime to KeepTheTime as «class isot»
    write KeepTheTime to fRef
    end try
    close access fRef
    end SaveTheTime
    on setTheDaysHoursMinutesSeconds(theSeconds)
    set TheTotalDays to theSeconds div days
    set TheTotalHours to (theSeconds - (TheTotalDays * days)) div hours
    set thetotalminutes to (theSeconds - ((TheTotalDays * days) + (TheTotalHours * hours))) div minutes
    set theTotalSeconds to theSeconds - ((TheTotalDays * days) + (TheTotalHours * hours) + (thetotalminutes * minutes))
    set the AnswerString to ""
    if TheTotalDays > 0 then set the AnswerString to the AnswerString & TheTotalDays & " Days "
    if TheTotalHours > 0 then set the AnswerString to the AnswerString & TheTotalHours & " Hours "
    if thetotalminutes > 0 then set the AnswerString to the AnswerString & thetotalminutes & " Minutes "
    set the AnswerString to the AnswerString & theTotalSeconds & " Seconds."
    return the AnswerString
    end setTheDaysHoursMinutesSeconds

  • Mailbox Folders Not Showing Mail Correctly

    Hello,
    I am kind of baffled at what my mail is doing. Here is a screenshot of what my mailboxes look like. When I send a message it doesn't show up in the "sent" or "sent mesages folder", those only show select messages that were sent weeks ago. Also the trash only shows messages that were deleted weeks ago and not any I just deleted. It is like my mailbox is 3 weeks behind.
    Also my inbox is deleting messages by itself!? I woke up this morning and 3 of the messages that were in my inbox that I received over the last couple days were gone? And finally, the drafts folder sometimes puts a sent message in it, but randomly and for no reason? It is like my mail program has a ghost. Any suggestions. I am really thinking of getting Eudora or somethign b/c I can't keep track of what I sent, if I need to fetch a deleted message, or even leave messages in my inbox without them being deleted.
    http://seasonsofwhite.com/mail.jpg

    Hey - thanks for the reply.
    To hopefully add to this scenario, from the newest reply from the user, this started happening as soon as they upgraded to Office 2013, so any past folders that were created in their old Outlook (2007) were visible, it's only when they now create a new folder
    from their new Outlook (2013), that the folder 'seems' like it isn't created, but when they check with another user that's still using Office/Outlook 2007, the new folder is there and usable.
    We're still waiting on confirmation, but from what we've been told, the folders are visible/usable in the OWA as well.  We're also checking with the 2nd user who was also upgraded to Office/Outlook 2013 to see if there's a visibility correlation issue,
    as well as whether there's a reverse to this (i.e. someone with 2007 creates a folder and whether the 2013 user can see that one)
    For the most part though, right now it seems only the one user with 2013 is having this issue, so begs whether it's a client issue, or maybe some setting on the Exchange side that's not translating to their Office/Outlook 2013.
    Going to schedule a repair of Office 2013 and will update when we try that (as well as the other), but in the meantime, any other notes/ideas are appreciated.
    Cheers

  • Search-Mailbox Search Query not returning correct results.

    Hi,
    I'd appreciate some assistance with the search and delete I'm trying to I'm run.
    I'm using the following command to find messages with a certain message class received before 01/01/14 in a mailbox.
    Get-Mailbox xxxxxxxxxxxxxxx | Search-Mailbox -SearchQuery '(Received:< 01/01/14) AND ("IPM.Note.Worksite.Ems.Filed")' -EstimateResultOnly | select displayname, success, resultitemscount,Resultitemssize
    When I first ran the command it returned 130,000 items, I ran it again with a -DeleteContent switch, all the items were successfully removed from the mailbox, great! However, when I look in the mailbox I can see ~1000 items with the message class in the command
    and dated 2013 or earlier, they meet the search criteria so I don't understand why when I run the command again it returns 0 items.
    Help!

    Hello,
    Based on your description, your cmdlet is ok.
    When you run the cmdlet with a -DeleteContent switch, the messages are not delete permanently. please try to run the cmdlet with a -DeleteContent switch and -Force switch to check the result.
    Besides, please use get-mailboxstatistics | fl cmdlet to check information about mailbox.
    Cara Chen
    TechNet Community Support

  • Search-Mailbox not attaching the infected emails in target folder and deleting the contents in exchange 2010 & 2013 coexistence

    Dear All,
    I have an issue with deleting circulated spam emails in my environment through search-mailbox
    We have Exchange 2010 & 2013  CU5 environment 
    I followed the search and destroy document for exchange 2010 
    http://windowsitpro.com/exchange-server-2010/search-destroy-email-content-exchange-2010
    Added the user to Discovery Management group
    Created a new role group as below 
    New-RoleGroup "Mailbox Import-Export Management" -Roles "Mailbox Import Export"
    Add-RoleGroupMember "Mailbox Import-Export Management" -Member Administrator
    I ran the below commands
    Search-Mailbox -Identity "[email protected]" -SearchQuery "Subject:'report'" -TargetMailbox "Administrator" -TargetFolder "Filter" -LogOnly -LogLevel Full
    The above command gets completed successfully and sends the log report  however im unable to see any attachments
    Similarly the deletecontent also gets completed successfully and logs result. But it does not delete the infected emails 
    Search-Mailbox -Identity  "[email protected]" -SearchQuery "Subject:'report'" -TargetMailbox "administrator" -TargetFolder "filter" -deletecontent -LogLevel Full
    Any idea why it is not fetching the infected emails in zip file and why it is not deleting but it is able to log in the target folder 
    Any help much appreciated
    Remember to mark as helpful if you find my contribution useful or as an answer if it does answer your question.That will encourage me - and others - to take time out to help you Check out my latest blog posts on http://exchangequery.com Thanks Sathish (MVP)

    Hi All 
    I managed to find the solution. Below command helped me in solving the issue 
    get-mailbox -ResultSize unlimited -IgnoreDefaultScope | search-mailbox -SearchQuery ‘Subject:"virus infected"’ -LogOnly -TargetMailbox administrator -TargetFolder filter -LogLevel Full
    get-mailbox -ResultSize unlimited -IgnoreDefaultScope | search-mailbox -SearchQuery ‘Subject:"virus infected"’ -TargetMailbox administrator -TargetFolder filter -deletecontent -LogLevel Full
    Remember to mark as helpful if you find my contribution useful or as an answer if it does answer your question.That will encourage me - and others - to take time out to help you Check out my latest blog posts on http://exchangequery.com Thanks Sathish
    (MVP)

  • Pulling specific subject with search-mailbox

    I'm trying to use search-mailbox in Exchange 2010 to find e-mails with a specific subject, but my query is pullling more than it should.  Here's what I've got:
    get-mailbox "Userbox" | search-mailbox -searchquery 'Subject:"Your e-mail will expire soon!"' -targetmailbox "adminbox" -targetfolder "adminfolder"
    It's finding the e-mails I'm looking for, but it's also pulling e-mails with subjects like "Your driver's license will expire soon" and "Contracts for your review".  How do I get the exact phrase?  Right now, it looks like it's
    OR-ing each word.
    Thanks,
    Matthew

    Hi,
    As the link mentioned which was provided by troy:
    http://help.outlook.com/en-us/140/ms.exch.ecp.newmailboxsearch_searchquery.aspx
    Exact phrases
    Use double quotation marks ( " ) to search for exact terms or phrases. For example, "cat and dog" finds messages that contain the exact phrase
    cat and dog. The search cat AND dog finds messages that contain both words somewhere in the message. Exact phrases can help you obtain more precise results.
    In addition,according to your requirement,you can try the following command:
    Search-Mailbox -Identity Usermailbox -SearchQuery 'Subject:"your e-mail will expire soon!" And From:[email protected]' -Targetmailbox adminbox -Targetfolder adminfolder
    Hope this hleps!
    Thanks.
    Niko Cheng
    TechNet Community Support

  • Search-Mailbox Question

    I would like to know if there is a way when doing a search-mailbox for "ALL" mailboxes in Exchange 2010, to make all results show in one single folder.
    Further explanation, We want to use -TargetFolder, however, I don't want the results to show up in "SubFolders" under the Target folder for each mailbox. I would like ALL results in on "Single" folder.
    Is this possible?
    Thanks

    Hi,
    We have to specify an target folder and target mailbox when using Search-Mailbox command.
    Please try following command to search mailbox and specify target mailbox and folder, for example mailbox One and folder Test.
    Get-Mailbox | Search-Mailbox -SearchQuery 'Delivery has failed' -TargetMailbox "One" -TargetFolder "Test" -LogOnly -LogLevel Full
    If you don’t add “-LogOnly”, it will search all mailbox and create subfolder for each mailbox under the target folder.
    More details about Search-Mailbox, please refer to blew link:
    http://technet.microsoft.com/en-us/library/dd298173(v=exchg.141).aspx
    “The LogOnly switch specifies that a search be performed and only a log be generated. Messages returned by the search aren't copied to the target mailbox. The logging level is specified by using the LogLevel parameter.”
    I hope it will help you.
    Best Regards,
    Allen Wang

  • Search-Mailbox -deletecontent...not deleting all items?

    Hi, I am trying to purge some data from my Exchange server. I am running:
    Search-Mailbox -id username -searchquery "system.message.datareceived:01/01/2011..01/09/2011" -DeleteContent
    The first time I ran this against a mailbox it went off and deleted a load of mail. But looking into things further, there is still lots of mail that was received in the period stated. Not sure why the cmd hasn;t got rid of this as well? Also tried system.message.datesent
    but again when I run this the log states that there is nothing to delete, even though I have over 200 emails from June-Sept. Whats the deal here?

    Hi,
    Please try the following command and check:
    Search-Mailbox -Identity <username> -SearchQuery "Received:> $('01/01/2011 00:00:00') and Received:< $('01/09/2011 23:59:59')"
    –DeleteContent
    Hope it helps. If this issue still occurs, please let us know.
    Thanks
    Sophia Xu
    TechNet Community Support

  • -DeleteContent switch for Search-Mailbox Cmdlet does not work

    Apologies if this isn't the right forum for this question. 
    I'm having trouble with the Search-Mailbox cmdlet, specifically when I'm attempting to use the -DeleteContent switch in order to delete a message from a specific user's mailbox. 
    I attempt to run the command: 
    Search-Mailbox -identity "Some User" -DeleteContent -SearchQuery 'Subject:"Spam Email Subject Heading"'
    And I get:
    A positional parameter cannot be found that accepts argument '-DeleteContent'.
        + CategoryInfo          : InvalidArgument: (:) [Search-Mailbox], ParameterBindingException
        + FullyQualifiedErrorId : PositionalParameterNotFound,Search-Mailbox
    Any idea what could be causing this issue? It's as if the shell does not recognize the existence of the -DeleteContent switch. I have no issues at all with the Search-Mailbox cmdlet except when it comes to using that switch. 
    Some background:
    - Yes, I am running the shell as an admin.
    - I'm running EMS on my Exchange server itself through an RDS instance.
    - Running Exchange Server 2010 - Version: 14.03.0181.006
    - My user account is a member of: Discovery Management, Organization Management, Recipient Management, Records Management, Server Management, and UM Management.
    Thank you in advance for any help any of you can provide!

    The exchange blog team has contained
    here with good explanation in detail about removing the specific user mailbox in exchange 2010. Please check this.

  • Search-Mailbox can't get all the items one time

    Support there are 10 items are satisfied the following search condition,then if I run the following commands, it should delete all the 10 items.
    but to my surprise, when I run the following command ,it just delete part of the 10 items, such as 5, or 8 .
    so I have to run the command once again to delete the remains items
    So my question is how to delete all of the 10 item one time? why I can't delete all of them one time?
    Search-Mailbox -Identity "administrator" -searchdumpsteronly -SearchQuery 'retentionpolicy:"NONARCHIVETAG"' -DeleteContent -confirm:$false -Force
    Please click the Mark as Answer button if a post solves your problem!

    Hi,
    Could you please create a new test mailbox and delete the messages by using subject query? Is it the same issue?
    Best regards,
    Belinda
    Belinda Ma
    TechNet Community Support

  • Search help is not triggering second time in interactive form

    Hi,
    I have online interactive form in WDABAP. And I have few search helps in the form, If i click on any search help it is opening and I can select the value and the same is populated to the field. But if i click it again search help is not opening.
    Only one time it is triggering and also after I clicked one serach help, other search helps also dont work.
    Can some one guide me? Is it something to do with scripting or any other configuration?
    Now Im using ALD7.1 and Reader version is 8.1.0.
    did any one faced this problem? Really appreciate if some one can help me on this.
    Regards,
    Ravi

    hi,
    The following code is generated in the preopen event of the valuehelp.
    // DO NOT MODIFY THE CODE BEYOND THIS POINT - 710.20061129084151.349066.349066 - ValueHelpDropDown.xfo
                       var processingValueHelp = ContainerFoundation_JS.getGlobalValue(event.target, "processingValueHelp");
                       if(processingValueHelp == false) {
                           ContainerFoundation_JS.setGlobalValue(event.target, "processingValueHelp", true);
                           this.rawValue = "";
                           this.clearItems();
                           ContainerFoundation_JS.SendMessageToContainer(event.target,
                                                                         "valueHelp",
                                                                         this.dataNode.somExpression.replace(/(xfa.?\.)(datasets.?\.)(data.*?\.)/, ""),
                                                                         this.rawValue,
                                                                         event.target.mouseX,
                                                                      event.target.mouseY);
                       // END OF DO NOT MODIFY
    I have tried placing this code in click event instead of preopen.But still no use. Can we make changes to this code? Can some one give me some idea what changes need to be done..
    Regards,
    Ravi

  • The world clock on my IPOD touch is not telling the correct time

    My IPOD touch world clock is not displaying the correct time and the edit feature is not working to change the time

    See:
    iOS: Wi-Fi or Bluetooth settings grayed out or dim
    If not successful, an appointment at the Genius Bar of an Apple store is usually in order.
    Apple Retail Store - Genius Bar

  • TS1702 The Calendar app that came on my i4S Phone does not sync the correct time for items posted on my Yahoo Calendar.  Actually, they post exactly 4 hours earlier than the correct time on my Yahoo Calendar.  Does anyone have a "fix" to correct the "time

    The Calendar app that came on my i4S Phone does not sync the correct time for items posted on my Yahoo Calendar. Actually, items post exactly 4 hours earlier than the correct time on my Yahoo Calendar.   My i4S is in the correct New York time zone.  Help?

    I posted this question a while ago and didn't receive any responses but there are a lot of people who have viewed it and 10 have said they have the same question so I thought I would update you that I added my nanny to my exchange server account (created an email for her) and I send all invites to that email address and they work.  So sending invites from an exchange server account to a non-exchange server account apparently is a bug so to solve it, get on an exchange server I guess.

Maybe you are looking for

  • How do I sort bookmarks in a folder in alphabetical order

    I have downloaded the latest version of Mozilla Firefox this morning, but I notice that the folders in my bookmarks are not in alphabetical order. I am a crafter so I do need them in order. Can you please tell me how to do this. If this cannot be don

  • Fix network connection timed out error 3259

    How do I fix network connection timed out error 3259?

  • Using MS Loopback Adapter

    Hi, I am running 10g at home on Windows XP Pro. I have installed 2 network connections, one for home internet (DHCP) and another one created with Microsoft Loopback Adapter for running Enterprise Manager. To run EM, I have to disable the DHCP connect

  • Automatically open movies in Quicktime Full Screen

    I know that if I open a movie file in Quicktime I can go to to: window/show movie properties/presentation/enter full screen mode when opened & then the movie will start on full screen when i play it. But how can i avoid this step if i want all movies

  • Birt in jdeveloper

    Anybody know anything about integrating birt into an adf project in jdeveloper?