Monday, June 30, 2008

Monitoring Logon Scripts via SCOM

In a large environment you need to know when something goes wrong. This is not necessarily because you want to know every issue that can occur, but because a single small issue can quickly grow into many small issues; which results in one large issue.

Say for instance that you have a logon script that maps the users home folders and some shared printers in a terminal server / citrix environment. If a user's printer fails to map correctly that could be the first symptom of a larger environmental issue that is effecting all users – whether they report it or not. So if we monitor this activity in SCOM then we will know what is failing, where it is failing, who it is failing for, and when it is failing – all this could hopefully direct us to why it is failing.

The solution is fairly simple: edit the logon script to identify and report failures, create a SCOM MP to catalog those failures.

Our logon script uses VBScript, so a simple subroutine can be added to check for an error code and then write the error to the NT Event Log. Then just call this sub wherever something may fail.

SUB CheckError(strSource)

IF Err.Number <> 0 THEN

WriteToLog strSource & " -- " & Err.Description & " " & Err.number & " (" & Hex(Err.number) & ")"

oShell.LogEvent EVENT_ERROR, "Printer.vbs" & vbCrLf & userName & " - " & strSource & " -- " & Err.Description & " " & Err.number & " (" & Hex(Err.number) & ")"

Err.Clear

END
IF

END
SUB


The SCOM MP simply uses the NT Event Rule to look for these events and report them.

No comments: