Please consider donating:


Monitor file age with Operations Manager 2007 (vbscript monitor)

In this post, I will explain one of the techniques to monitor the age of a given file, using vbscript and Operations Manager 2007

This is what the script looks like :

Option Explicit

‘ Script that returns the difference in number of days between now() and
‘ the last modified timestamp of a file
‘ feed the full path to the file as the first parameter
‘ Written by Peter Van Eeckhoutte
‘ Feb 2008

Dim oArgs
Set oArgs = Wscript.Arguments
Dim oAPI
Set oAPI = CreateObject("MOM.ScriptAPI")
if oArgs.Count < 1 Then
‘ If the script is called without the required argument,
‘ create an information event and then quit.
Call oAPI.LogScriptEvent(WScript.ScriptName,101,0,WScript.ScriptName+" script was called without any arguments and was not executed. ")
    Wscript.Quit -1
End If

Dim objFile
Dim ValueToReturn
Dim oFso
Dim oFile
Dim oBag
Dim filename
Set oFso = CreateObject("Scripting.FileSystemObject")

‘replace single slashes with double slashes
filename = Replace(oArgs(0),"\",\\)
‘see if file exists
if (oFso.FileExists(filename)) Then 
    set objFile = oFso.GetFile(filename) 
End If

Set oBag = oAPI.CreatePropertyBag()
Call oBag.AddValue("DaysAgo",ValueToReturn)
Call oAPI.LogScriptEvent(WScript.ScriptName,101,0,ValueToReturn) Call oAPI.Return(oBag)


This is how it works

Open the authoring pane in OpsMgr and go to monitors

Find the Windows Computers (or any other scope that contains computer objects). Create a new unit monitor (Script based, two state monitor) and save the monitor in your custom management pack. Specify a good name, make sure to leave the monitor disabled for now (uncheck the "Monitor is enabled" checkbox at the bottom). We only want to run this script on one server, so we will create an override for this server lateron.

Quick note before continuing : you’ll have to create a monitor for each file that you want to watch. So you can put the name of the server and the name of the file in the monitor name field.

Configure the schedule (e.g. once per day)

Define the script filename (don’t forget the .vbs extension) and set a timeout. This is a just a simple script, so 1 minute will be fine.

Click "Parameters" and enter the absolute path to the file that you want to monitor. (between double quotes)

Paste the entire script from the table above in the Script: field

Expressions :
Unhealthy :
Parameter Name : Property[@Name=’DaysAgo’]
Operator : is greater than
Value :

(Note : as you can see in the script, if the file is not found, the script will return 9999… it’s up to you how you want to deal with that. You can write another monitor that checks for the presence of the file and look at the 9999 value… )

Healthy :
Parameter Name : Property[@Name=’DaysAgo’]
Operator : is less than or equal to
Value :

Finish the monitor by allowing the monitor to create an alert. In the alert description field, you can specify some text :

The file is $Data/Context/Property[@Name=’DaysAgo’]$ days old, which is older than …. days

Save the monitor

Edit the monitor again and create an override for the server that contains the file you want to look at.

Enable the monitor for that server, and wait until it kicks it.

© 2008, Peter Van Eeckhoutte (corelanc0d3r). All rights reserved.

2 Responses to Monitor file age with Operations Manager 2007 (vbscript monitor)

Corelan Training

We have been teaching our win32 exploit dev classes at various security cons and private companies & organizations since 2011

Check out our schedules page here and sign up for one of our classes now!


Want to support the Corelan Team community ? Click here to go to our donations page.

Want to donate BTC to Corelan Team?

Your donation will help funding server hosting.

Corelan Team Merchandise

You can support Corelan Team by donating or purchasing items from the official Corelan Team merchandising store.

Protected by Copyscape Web Plagiarism Tool

Corelan on Slack

You can chat with us and our friends on our Slack workspace:

  • Go to our facebook page
  • Browse through the posts and find the invite to Slack
  • Use the invite to access our Slack workspace
  • Categories