• Jeff Moden (5/2/2014)


    lsatchell (5/1/2014)


    This article was the subjectline feature article 2nd May 2014 SQLServerCentral e-mail newsletter.

    Come on guys, a circa 2010 solution featuring a VBscript!? Where's the powershell updated equivalent? VBscript should be relegated to Office macros by now....

    Regards, Leigh.

    Dan Guzman-481633 (5/2/2014)


    Any thoughts to using PowerShell instead of VBScript?

    buddy__a (5/2/2014)


    Any thoughts on using Powershell instead of VB?

    Edit:

    Apparently DanGuzman and I both had the same thought while not reading the entire thread.

    Why? It still works even after more than 3 years. 🙂 Would PoSH make it better in some way? If so, I'm all for it. If not, I wouldn't change it.

    Great point, I'm going to tell the company I'm working for to stop upgrading all those working VB6 apps. I'm not sure why Geoff bothered to use VBScript in the first place when he could have done this all in an assembly language app.

    Or you could replace stuff like this:

    Set objWMIService = GetObject("winmgmts:" _

    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

    ' get the events we want

    query = "Select * from __InstanceCreationEvent" _

    & " " & "where TargetInstance isa 'Win32_NTLogEvent'" _

    & " " & "and TargetInstance.Logfile = 'Application'" _

    & " " & "and (TargetInstance.EventType = 1 or TargetInstance.EventType = 2)" _

    & " " & "and (TargetInstance.SourceName like 'MSSQL%')"

    ' get ready to insert into our DBA table

    Set colMonitoredEvents = objWMIService.ExecNotificationQuery(query)

    with this:

    Get-EventLog -LogName Application -Source "MSSQL*" -EntryType Warning,Error

    I don't get technology workers that say stuff like this. Working with the bottom code is much easier (and that's the whole purpose of technology) than all the string concatenated stuff above. Also, everyone new to the administration game (be it server admin or database admin) is learning Powershell, not VBScript. VBScript is dead, the new king is Powershell and it is so much better than VBScript. Geoff did a great job but there is nothing wrong with upgrading to new technology.