Easy Basic Script Monitor - Why doesn't work?


  • HI,

    I have a script which should not run on saturdays or sundays. It works when I run it outside of SCOM but not as a monitor.

    I've used

    dtmToday = Date()
    dtmDayOfWeek = DatePart("w", dtmToday)

    (look in script)

    Still it runs on Saturdays and Sundays. Help appreciated!


    Dim filesys, Filobjekt, LastModified, strDiff, objParameters, objArgs

    Set objAPI = CreateObject("MOM.ScriptAPI")
    Set oBag = objAPI.CreateTypedPropertyBag(StateDataType)
    FilFullSti = Wscript.arguments(0)
    GrenseverdiTimer = CInt(Wscript.arguments(1))

    Set filesys = CreateObject("Scripting.FileSystemObject")
    Set FilObjekt = filesys.GetFile(FilFullSti)
    LastModified = FilObjekt.DateLastModified
    strDiff = CInt((DateDiff("h",LastModified,Now())))
    wscript.echo FilFullSti & " " & LastModified & " " & strDiff

    dtmToday = Date()
    dtmDayOfWeek = DatePart("w", dtmToday)

    If dtmDayOfWeek <> 1 OR dtmDayOfWeek <> 7 Then
    If strDiff > GrenseverdiTimer Then

    Call oBag.AddValue("State","BAD")
    Call oBag.AddValue("Path",FilFullSti)
    Call oBag.AddValue("Threshold",GrenseverdiTimer)
    Call oBag.AddValue("Fil",strDiff)
    Call objAPI.Return(oBag)

    Call oBag.AddValue("State","GOOD")
    Call objAPI.Return(oBag)
    End If
    End If

    Thanks in advance, Best Regards

    Wednesday, August 28, 2013 11:15 AM


All replies

  • Hi

    if you have configured script base monitor to run under default profile scom agent run script under Default action account and script will fail to run if account do not have sufficient permissions.


    sridhar v

    Thursday, August 29, 2013 8:07 AM
  • You should implement the scheduler module to handle this, otherwise the script will always execute. There is no need to use logic in the script to determine when it should run.

    Jonathan Almquist | SCOMskills, LLC (

    Thursday, August 29, 2013 9:22 AM

    Vladimir Zelenov |

    Tuesday, September 03, 2013 5:07 PM
  • But how to use it? Exporting the custom MP and pasting it in or creating the rule in the 2007 authoring console?  :)  Thanx

    Thanks in advance, Best Regards

    Friday, September 06, 2013 12:48 PM
  • But how to use it? Exporting the custom MP and pasting it in or creating the rule in the 2007 authoring console?  :)  Thanx

    Thanks in advance, Best Regards

    Here is an example

    Jonathan Almquist | SCOMskills, LLC (

    Friday, September 06, 2013 6:56 PM
  • I am not very technical, sadly. I've got the System.Scheduler filled out like I want it. Can I use it for a monitor, if not what changes do I need, and where do I past it in the MP.XML? In the unit monitor-tag or some where else? For one who has worked with HP products it still really shocking to me how slow and intricate SCOM is to use on custom authoring.

    Here is my System.scheduler:

    <Rule ID="Microsoft.Samples.ScheduledRule" Enabled="true" Target="Windows!Microsoft.Windows.OperatingSystem" ConfirmDelivery="true" Remotable="true" Priority="Normal" DiscardLevel="100">
        <DataSource ID="DS" TypeID="Windows!Microsoft.Windows.EventProvider">
                <XPathQuery Type="UnsignedInteger">EventDisplayNumber</XPathQuery>
                <Value Type="UnsignedInteger">1000</Value>
      <ConditionDetection ID="Schedule" TypeID="System!System.SchedulerFilter">
            <ExcludeDates />
        <WriteAction ID="Alert" TypeID="Health!System.Health.GenerateAlert">
          <AlertName />
          <AlertDescription />
          <AlertOwner />
          <AlertParameters />
          <Suppression />

    Thanks in advance, Best Regards

    Monday, September 09, 2013 8:49 AM