Create a file as reponse to a Alert with the Alert Parameters

 

As a response to a alert we can run a script, what I tried here was how can I run and when I run how can I use the parameters of the alert if I need to do something and for that I just exported the data and wrote it to a file named alert .txt.

This screenshot of how to set the alert when creating an alert.

Screenshot and script

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

Though Parameters to the script shoes only the target ID you can even insert the data of the alert as well.

Script

====

'====================

'testscript.vbs

'Description: This script writes the text passed as argument and in our case it is alert parameters

'This information can be used to do many things.

'====================

On Error Resume Next

Const ForWriting = 2

Const ForReading = 1

Const ForAppending = 8

Const TristateFalse = 0

Set fso = CreateObject("Scripting.FileSystemObject")

Set GObjArgs = WScript.Arguments

GStrCmd = GObjArgs(0)

Call crypt(GStrCmd)

 

 

Sub crypt(msg)

n = Len(msg)

 

set objArgs = WScript.Arguments

 

for each strArg in objArgs

                msg = msg & strArg & “ “

next

 

    output = msg

 

Set GObjLocalF = fso.OpenTextFile("c:\test\Test.txt",ForWriting,True)

GObjLocalF.WriteLine output

GObjLocalF.Close

End Sub

 

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

 

What I tried here was to just understand how the parameters can be brought in to the script so that we can do wonders using VBSCRIPT for recoveries of the alerts and make \ automate SCOM more. Hope this information will be useful.

 

Hope this will be helpful