Home » Microsoft Operations Manager 2005 » Files created last X hours including Y in the filename

Files created last X hours including Y in the filename

This is a script that checks if there is a new file, contains a keyword, and that the file has been created last X hours. For example if you have a couple of servers uploading files every hours, you can check with this script if all servers have uploaded a new file the last hour. Even if the filename is not always the same, for example many applications add a timestamp to the filename like server05_20081012.
Configuration.txt contains all keywords that should be included in a filename. Contoso_filecheck.hta is a GUI that you can use to add keyword, delete keywords and show current keywords. contoso_filechecker.vbs is the script that does the filecheck.

  1. The script counts number of files in the folder, that was created last X hours (default folder is C:\LogFiles and default time is 24 hours)
  2. The script creates an array of all the files that was created last X hours
  3. The script loops all selected files and checks if the keyword is in the filename. It then moves on to the next keyword and loops all selected filenames.
  4. If the keyword, for example a server1, is in Configuration.txt but there is no file including server1 created last 24 hours, a local event will be created including the time configuration and the keyword.
  5. You can configure MOM 2005 or Ops Mgr to pickup these events and generate an alert.

Download the script here.