Script to check for files for a period of time RRS feed

  • Question

  • Here is my script the script correctly checks it for the first time but I would want it to check for a 60 minutes.  the loop seems to work but I cannot get to work for 60 minutes then kick out and send either a success or failure email.  Is there a simple way of ding that?

    #setup loop
    $TimeStart = Get-Date
    $TimeEnd = $timeStart.addminutes(2)
    Write-Host "Start Time: $TimeStart"
    write-host "End Time:   $TimeEnd"
    $files = Get-ChildItem -name Z:\folder1


    $TimeNow = Get-Date
    if (Test-Path "Z:\folder1\filename.csv") 



    Start-Sleep -Seconds 10
    #While (get>>date).hour -e 5 ) 

    # Until ($TimeNow -ge $TimeEnd)

    #while (!(Test-Path "Z:\folder1\filename.csv")) 
    # Start-Sleep -s 10 

    Then send an email

      This script seems to stall winrar extracting the file
    • Edited by MattNad Wednesday, March 20, 2019 7:40 PM
    Wednesday, March 20, 2019 7:39 PM

All replies

  • Have you heard about scheduled tasks?

    Live long and prosper!


    Wednesday, March 20, 2019 8:34 PM
  • Yes it is scheduled to run but it seems not quit and still ties up winrar
    Wednesday, March 20, 2019 9:10 PM
  • Hmmm ... you don't have anything about winrar in your code? How is winrar involved in this? What is it what you're actually trying to do?

    BTW: when you post code pease format it as code using the code posting tool provided on the edit bar of the post editor. You should even fix this in your initial post, please.


    Live long and prosper!


    Wednesday, March 20, 2019 9:28 PM
  • Hi,

    Was your issue resolved?

    If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.

    If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.

    If no, please reply and tell us the current situation in order to provide further help.

    Best Regards,


    Just do it.

    Wednesday, March 27, 2019 6:36 AM