Script to Find latest Modify date, and email alert if last modify is older than 4hrs or so

So, I want to monitor a directory, and get an alert if any file in the directory was not modified in the last, 4 hours or so.  
I think I'm on the right track, but I'm missing some pieces here.  Any suggestions?
Here's what I got so far:
::Set time and date to use later if needed
set currentTime_Date=%time% %date%
::For loop to pull the last file (I can't seem to pull the last modify time/date with it... this is where I need a hand)
FOR /F "delims=" %a IN ('DIR "*.*" /B /O:D') DO SET NewestFile=%a 
::Email latest file using blat
blat.exe -to [email protected] -server [email protected] -f [email protected] -subject "File Checker" -body "test" -attach %NewestFile%
(Not sure if I can use the variable for my newest file here or not)
Any suggestions?

Upgraded to V4 PS, and same error with this script (Note you had the variables and first function doubled up)
$folder='C:\v1\temp'
$Logfile = "C:\PicksheetMonitoring\WhileLoop.log"
function logit($msg){
$msg='[{0}]{1}' -f [datetime]::Now, $msg
$msg|Out-File $logfile -append
logit 'Running check'
if([datetime]::Now - (Get-Item $folder).LastWriteTime -gt [timespan]'0:4:0:0'){
Send-MailMessage -to "Picksheet Analysis <[email protected]>" -from "Picksheet Alerting <[email protected]>" -subject "It's been at least 4 hours since last Automation run" -smtpserver "exch01.domain.com" ..
logit 'alert sent'
}else{
logit 'all files good'

Similar Messages

  • Someone is using faebook to run java script to get data and email from me in windows 8

    someone is using faebook to run java script  to get  data  and  email  from  me in  windows  8

    Is this a developer question?
    Jeff Sanders (MSFT)
    @jsandersrocks - Windows Store Developer Solutions
    @WSDevSol
    Getting Started With Windows Azure Mobile Services development?
    Click here
    Getting Started With Windows Phone or Store app development?
    Click here
    My Team Blog: Windows Store & Phone Developer Solutions
    My Blog: Http Client Protocol Issues (and other fun stuff I support)

  • Recently the sound on my Iphone 4 for texts, and email alerts started working intermittently.  I have upgraded to the latest software and the Apple store even replaced the phone but safe issues

    Recently the sound on my Iphone 4 for texts, and email alerts started working intermittently.  I have upgraded to the latest software and the Apple store even replaced the phone but safe issues

    For each mail account, along with designating a primary SMTP server, you should be able to just turn off any and all other SMTP servers you have listed.  In that case, if there is a problem with comcast, the message send should just fail.
    Also make sure your comcast smtp settings are correct (port, likely 587 but might be something else for comcast, whether you should be suing SSL or not, do you need authentication or not).
    You might find the comcast forums useful for getting the settings right - I found this:
    http://forums.comcast.com/t5/E-Mail-and-Xfinity-Connect-Help/iphone-email/m-p/66 1151?view=by_date_ascending#M131151
    The second poster notes, SSL should be on, authentication should be "password" and you should be using port 995

  • How can i transfer all my datas and email form old Mac G5 to new iMac ?

    How can i transfer all my datas and email form old Mac G5 to new iMac ?

    Generally Mugration Assistant will suffice importing all Data ito a new user, but you can manually import it...
    Users/YourUserName/Library/Mail
    Users/YourUserName/Library/Mail Downloads
    (Could be a different folder here if you chose such in Mail Prefs)

  • How do I find out the date and time a picture was taken on my Ipad?

    How do I find out the date and time a picture was taken on my Ipad?

    Photo Manager Pro
    http://i1224.photobucket.com/albums/ee374/Diavonex/Album%202/7a2b3650710f4bded81 ab75dda6a3ee5.jpg

  • Where do I find my upgrade date and how do I find out when I bought the phone??

    I need to know where I can find my upgrade date and is there any way to find out when I started my services with Verizon?someone help plezzzzz! thanx

    Log on to your account, and click on the picture of your phone. It will show you when you can upgrade and when your contract ends. You can go back two years (or one year, if you opted for a one year contract) to figure your start date for that contract.
    If this was not your first contract, and you've been with Verizon for several years, you may need to call customer service to find out your original start date.

  • How to set alert threshold and email alerts?

    Hi!
    I have configured Solution manager 3.2 to monitor
    our R/3 systems.
    I want to be able to set the threshold for  tablespace
    usage and be able to send an email if the usage
    of the tablespace is 80% full.
    Could anybody tell how to implement it?
    Thanks!

    Hi Christy:
    There are different approaches to configure alerts, if you are using Solution Manager; I think you can benefit if you choose SolMan and the Central System (CEN) to handle all the monitoring and email alerting.
    If this is the case, you will need to install the CCMS Agents on every satellite system in order to trigger remote alerts.
    Let me know what is your idea and I can follow with you with the required steps.
    Best Regards,
    Federico G. Babelis
    NetWeaver Certified Consultant
    GAZUM Technologies S.A.
    Consulting Services and Software Solutions
    http://www.gazum.com
    ...download FREE Marketplace Manager at: http://www.gazum.com/products

  • Can we find out the date/time when the datafile last extended?

    Hello all,
    Can we find out the date/time when the datafile last extended?
    Is it possible to find out from the alert.log file?
    Correct me if I am worng?
    Thanks in advance
    Himanshu

    In continuation with the earlier post, can you tell me what sort of entry should be search if the above information is available in the alert.log file?
    Thanks
    Himanshu

  • IPhone 5 iOS 8.1.  Message and email alerts don't work.  Help!

    Message and email alerts are not working.  Vibration working fine.  Alerts also produce vibration.  I've seen a number of similar posts.  Thanks!

    OK. Called my service provider today. Apparently razmee209 was right. Bell/Virgin network is experiencing LTE problems since September and it affects random people all LTE phones. They said they are working on it. And the solution for now is to turn LTE off and keep the phone on 3G network.
    Hopefully it will be fixed soon.

  • Why have my purchased text and email alerts vanished?

    II'm not connected to I tunes and have purchased 2text alerts and email alerts. After assigning them, they disappear. Where are they?

    Thanks for the reply. It was after the upgrade. I brought the same alerts again afterwards (it knew I had already purchased them and asked me if I wanted to buy them again). I did but within a day, they had vanished again! Be careful not to buy them again until Apple sort this costly issue out!! They now owe me money!!!!

  • Finding the initial date and time of a modified instance of  reccurnt evnt

    The problem situation is as given below:
    I have created an event recurrent using the outlook client. I them modified one
    of the instance in it to occur in a data and time different from the existing
    date and time.
    Using the CAPI i wish to retrieve the initial date and time when the instance
    occured. According to documentation i should have the initial date and time in
    the Recurrence ID parameter. When i look at the icalendar i see that the
    recurrenceid matches the start date of the current instance and not the initial
    date and time. I am using the fetchEventByUID in the CAPI API set.
    Is this behaviour of changing date and time of the recurrence-id the expected
    one or is there any problem in the configuration on my machine.
    Counting on some insight into the parameter where the initial date and time of the event are stored.
    Best Regards
    Joyce

    Hi Joyce,
    The sdk always sets the recurrence-id to be the starttime of the instance.
    So the behavior you encountered is what one should expect with the sdk.
    There were some changes in a 10G to correct this situation for a given service. (i.e. have the initial date and time in the Recurrence ID parameter, for instances of the recurring set).
    This fix would not be available for the public sdk version, but given that this feature is important for your application, you could log a tar and it might become available in some 10G patch.
    Regards,
    Jean-Philippe Guguy

  • Script to update vendor inactive date and invoice match option

    As part of a review of our precure to pay process in 11.5.10, we have to make a change to a large number of suppliers (vendors).
    We want to disable about 7000 suppliers by setting the inactive date and for the remaining suppliers change the invoice match option from receipt to purchase order
    There does not appear to be any api that I can use to make these changes.
    Does anyone have any experience in using a baisc update script to change the data.
    Scripts would be something like:
    Inactivate suppliers
    update po_vendors
    set end_date_active = sysdate
    where vendor_id in <list of vendors to update>
    update po_vendor_sites_all
    set inactive_date = sysdate
    where vendor_site_id = <list of vendors sites to update>
    Change invoice match option
    update po_vendors
    set match_option = 'P'
    where vendor_id in <list of vendors to update>
    update po_vendor_sites_all
    set match_option ='P'
    where vendor_site_id = <list of vendors sites to update>

    Hello.
    In your place i would not have the guts to use SQL for a task like that. You know what Oracle says about using tools to modify data in the database. They always say that it is not supported and to use forms to modify the data. So I would suggest you to use a tool like DataLoad to query and modify your suppliers.
    Octavio

  • Issue in finding  GR posting date and quanity for Purchase order item

    Hi All,
    I have a requirement to list all PO items with Goods receipt posting date and quantity.
    So for each po item I have fetched Goods receipt posting date and quantity from table EKBE for movement type 101.
    But in transaction ME23n   in PO history tab it is displaying 3 records.
    2 are movement type 101 and 1 is movement type 102 GR quantity with minus sign.
    How  to find out Goods receipt posting date and quantity.
    what are the movement types we  have to consider.
    Thanks,
    Jwala

    movement type 102 is for GR for PO reversal that is why the quantity is negative.

  • How can I find my contract date and length online?

    I've searched everywhere and can't find anywhere online in MyBT that has the actual details of my contract date and length. I know I renewed my  line rental in advance and have Option 3 phone and broadband. I need to know, if I have paid a year's line rental, does that mean I'm automatically contracted to a year's Option 3 also?
    It would be SO much simpler not to have to waste hours going round in circles on the website. It is as though contract info that is personal to the subscriber is deliberately hidden. I can't think of any other provider who does this.
    All it would take is : Your contract started:....... Your contract ends..........
    Not rocket science!

    If you contact live chat at this link they can tell you http://bt.custhelp.com/app/contact/c/2902/?s_intcid=con_intban_sanda_contact_us_chat_from_forums
    If you want to say thanks for a helpful answer,please click on the Ratings star on the left-hand side If the reply answers your question then please mark as ’Mark as Accepted Solution’

  • How to get the latest Change date and time of a M.O. from View VIAUFKST

    Hi All,
    I want to get the latest date and time of a M.O. from view
    VIAUFKST. I have written the query like this...
      SELECT AUFNR
             AEDAT  " Changed Date
             AEZEIT " Changed Time
        FROM VIAUFKST
        INTO TABLE I_VIAUFKST
       WHERE AEDAT >= W_LASTRUN_DATE
       ORDER BY AEDAT DESCENDING.
    but its not giving me right results... Pls help me out on this or suggest me the right approach to achieve the same...As this is very critical issue...
    Advance Thanks and Points Gauranteed...
    Suresh

    > SELECT AUFNR
    >          AEDAT
    >          AEZEIT
    >     FROM VIAUFKST
    >     INTO TABLE I_VIAUFKST
    >    WHERE AEDAT >= W_LASTRUN_DATE.  
    >
    >   IF NOT I_VIAUFKST[] IS INITIAL.
    >    SORT I_VIAUFKST BY AEDAT AEZEIT DESCENDING.
    >    READ TABLE I_VIAUFKST INDEX 1.
    >   ENDIF.
    >
    > The above statement is giving me different results...
    > such as...
    >
    >  1. 30/11/2005 19:20:11
    >  2. 29/11/2005 22:10:09
    >  3. 30/11/2005 20:56:09
    >  4. 28/11/2005 23:10:09
    >
    > by using the above SORT statement i am getting the
    > fourth record as the latest, where as it should give
    > me the third record....
    >
    > Please advise,
    > Suresh.
    Hi Suresh,
    The reason why you are getting this result is because the system is interpreting the DESCENDING only for AEZEIT not for both. Change it to
    SORT I_VIAUFKST BY AEDAT DESCENDING AEZEIT DESCENDING

Maybe you are looking for

  • HT204053 we have two apple ids in our household.

    How do we both login to iTunes? How can we share media and not Contact information?

  • Creation of EDI 820 fromat for outgoing payments in SAP

    Hi Experts, We have a requirement where in we need to create an outgoing  payment file in EDI820 with in SAP. We basically need to create specifications in EDI820 format for the bank to print checks and make wires and EFT payments. That EDI820 file w

  • I want to edit an existing .rtf file from my PC on my iPod Touch. What do I have to do?

    I have a new iPod Touch, and an existing .rtf file on my Windows 7 PC that I wish to edit when traveling. I want to be able to do this regardless of having an internet connection.  What app(s) do I need, what file type should I convert the .rtf to, a

  • Ipod wire not working?

    So starting around December, my ipod would be so difficult to connect. When I'm trying to charge it and I move my ipod, it would unconnect and reconnect even though the wire is still attached to the ipod. I thought it was an ipod wire problem so I bo

  • Issues using Oracle SQL server Developer migration work bench

    Hi all, We are trying to migrate the application databases from SQL server 2000 to Oracle 10g using Oracle SQL Developer 1.2.1.32.13: Following is the list of issues that we faced while trying out this migration on dev environment. 1. The data migrat