Kaseya Community

Need help with SQL Query

  • To all,

    Hello. Looking for a little help. I am trying to write a K script that checks if the file BEUpdateOps.EXE (executable file to run Live Update for just Backup Exec) is on the machine, and if so, to run it.

    Have been struggling. Worked with a K Support person today, but still no luck.

    I can probably handle to balance of the work, but I am stuck on doing the SQL query. I basically want to query the Installed Apps table for the file BEUpdateOps.EXE, with the current machine GUID, and if found, get the path.

    The following is the code supplied by the K Support person, but it is failing on the SQL line. He did not know how to fix it. I am pretty good a most Kaseya scripting items, but I never did any SQL queries.

    Any help in getting this script to work would be greatly appreciated.

    Lloyd


    Script Name: Kaseya Test for File
    Script Description:

    IF True
    THEN
    Get Variable
    Parameter 1 : 10
    Parameter 2 :
    Parameter 3 : agentTemp
    OS Type : 0
    Get Variable
    Parameter 1 : 6
    Parameter 2 :
    Parameter 3 : agentname
    OS Type : 0
    Get Variable
    Parameter 1 : 11
    Parameter 2 : SELECT a.dirpath FROM auditRsltApps a, machNameTab b WHERE a.agentguid = b.agentguid and b.displayname = '#agentname#' and a.ApplicationName like 'BEUpdateOps%'
    Parameter 3 : Path
    OS Type : 0
    Send Message
    Parameter 1 : path = #Path#
    Parameter 2 : 1
    OS Type : 0
    ELSE



    Legacy Forum Name: Need help with SQL Query,
    Legacy Posted By Username: lwolf
  • Lloyd,

    Can you even use a SQL query in the script directly? Or do you need to create a custom SQL View on the K server using that query and access that view from the script?

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: rkniffin
  • I don't think you can perform a SQL query from the script. From my experience, you can only specify a view, column, and machine. The format would be SqlViewName/ColumnName/mach.groupID. Omit the mach.groupID and it will use the machine you run the script on. This format is stating SELECT ColumnName FROM SqlViewName WHERE mach.groupID = whatever. It does not allow you to specify any other parameters. I tried adding an AND statement but it just sees it as part of the machine name.

    You may want to try using the "Get Directory Path From Registry" and "Execute File in Directory Path" options within the script. You would need to find where the path for that application is specified within the registry. Or, as rkniffin said, you could create a custom view that pulls just the agent name, app name, and app path. Then you coud use CustomViewName/AppPath/MachName to get what you need.

    Also, I checked several of our servers with Backup Exec and only one of them had the Beupdateops.exe. I ran it and it just said it registered itself with Liveupdate and it set mode to optout.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: SteveR
  • Looks to me like the beupdateops.exe is only installed with the main Backup Exec application, maybe with the the console, but not with machines with the remote agents.

    Also, it's always in the same directory as the Backup Exec install.

    So, you should be able to use the path found in HKEY_LOCAL_MACHINE\SOFTWARE\Symantec\Backup Exec For Windows\Backup Exec\12.5\Install\Path

    So, with the path being known, you can test for the file. Unfortunately, the key name changes based on the installed version of BE ...

    Doesn't solve your SQL issue, but it may offer a different way of testing for the existance of the file you are looking for...

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: Lmhansen
  • Lmhansen ,

    Thanks very much. Someone on my team suggested a similar approach this afternoon. I think that actually does work around the issue, and get me what I need.

    As you pointed out, I will probably have to write a few subscripts to test for BE v11, v12 and v12.5.

    Thanks for the help.

    Lloyd

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: lwolf
  • You can query the database from a script but it requires a bit of legwork.



    My WOL script does this and you should be able to use the same methods



    http://community.kaseya.com/xsp/f/28/t/6222.aspx

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: T2Craig