Quantcast
Channel: Operations Manager - General forum
Viewing all articles
Browse latest Browse all 11941

How do you edit this VB script to include file extensions?

$
0
0

This answer and VB script came from Roger "Microsoft Hopeless Guy" back in May 2013....

http://social.technet.microsoft.com/Forums/systemcenter/en-US/b4754c04-dd1e-4274-85f0-b2e30adc8fc7/scom-2012-file-monitoring?forum=operationsmanagergeneral

I have a question, how would you replace the "trace" file reference in the script with a specific file extension?  I tried various ways, but unfortunately my code is not working.

I have a similar SCOM monitoring request as the original poster back in May 2013, but my user wants to be alerted when a file with a particular extension is created in a folder?

Any advice?

Thanks!

PS- the VB script is below...

===============

You may create time script monitor and the script is similar to

Dim fs, f, foldername,fd

set oAPI=CreateObject("MOM.ScriptAPI")

set oBag=oAPI.CreatePropertyBag()

Set fs = CreateObject("Scripting.FileSystemObject")
   foldername="c:\temp"

   status="OK"
    Set fd = fs.Getfolder(foldername)

    for each f in fd.files

             if instr(f.name,"trace") then

                 status="NOT OK"

                exit for

            end if

    next  
 
   
Call oBag.AddValue("Status",status)
Call oAPI.Return(oBag)

IN this example, I assume the monitor file is c:\temp and the trace flle with file name "*trace*"

Roger


Viewing all articles
Browse latest Browse all 11941

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>