Kaseya Community

custom database views for use within scripts?

  • i have written a script to do automated test restores using TrueImageCmd.exe. however, since image locations and passwords vary across machines, i need to reference variables that contain these values (it looks like i need to grab the imageLoc and backupPass columns from the dbo.backupParams table). i have checked the kaseya documentation, but i dont see any way to grab these values for use in a script. is there some (maybe undocumented) way to do this? if not, i am capable of either making my own database view or modifying an existing one. im just not sure if doing this will automatically create the variables within kaseya (e.g. #vMyCustomView.Column#). has anyone done this before?

    Legacy Forum Name: custom database views for use within scripts?,
    Legacy Posted By Username: MikeConigliaro
  • See: http://community.kaseya.com/xsp/f/28/t/5806.aspx



    I am still finessing the script but I was able to create the custom view and access it from the script.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: trebligb
  • thanks for the reply. i created the following view:


    SELECT m.agentGuid, m.machName + '.' + m.groupName AS Machine_GroupID,
    b.imageLoc AS imageLocationVol,
    b.ftpPath AS imageLocationFldr,
    b.backupPass AS imagePassword

    FROM dbo.backupParams AS b
    INNER JOIN dbo.machNameTab AS m
    ON b.agentGuid = m.agentGuid


    now i can access the the image locations and password defined for each machine using the following kaseya script variables:

    #vFandotechBackupConfiguration.imageLocationVol#
    #vFandotechBackupConfiguration.imageLocationFldr#
    #vFandotechBackupConfiguration.imagePassword#


    note to others who find this post and want to make their own custom views: i made an assumption based on how other views looked (but i did not verify) that the Machine_GroupID column has to exist in order for kaseya to know which row to select. i dont know how kaseya would know otherwise.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: MikeConigliaro
  • As far as I can tell that is correct that the machine_GroupID needs to be there. My view did not work until I added that as an alias.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: trebligb
  • Hi,

    To access the SQL views, you may need to first get the connection to the database from your script. How did you know the SQL-user ID and the corresponding password? Particularly, when the database user is SQL-user (i.e. SQL authentication). Basically, my question is that how did you get the connection to the database in the first place?

    -Ramesh

  • kaseya already has a connection to the DB so as long as the view is in the ksubscribers DB you can reference it.