Kaseya Community

Help Writing a Script Please.

This question has suggested answer(s)
All Replies
  • This is the second time I try to post a message and it ends up blank. . . .

    I was trying to create a way to report on the Warranty status of Monitored machines, this is somethign I was really excited about.

    But now I'm stuck, so far I've managed to create a VBS script that outputs a file called warranty.dat for HP, Dell and Toshiba machines.

    The outputed file would look like this:

    2010-07-11

    HP HW Maintenance Offsite Support

    Two lines of text, the first being the end date for the warranty and the second being the Warranty Type.

    Using Kaseya's scripting I would pull the SQL data from vSystemInfo[Manufacturer] and vSystemInfo[System Serial Number] and store them into two variables in a script.

    Then I would execute a VBS script if it were HP, Toshiba or Dell to find the warranty info and create the WARRANTY.DAT file.

    Now I'm at the point where I've created a variable from a file but alas, i'm at a loss.

    How do I refer to the two individual items in the file, eg: line1. Line2.

    Then secondly, how do I create a new colum in under the vSystemInfo.

    The nice part of this, is once shared someone may be able to figure out how to add Acer, Fujistu and other vendors or by creating the file manually at time of deployment warranty info can be 'easily' tracked.

  • Pass the two Kaseya variables to your VB Script as parameters. To add a new column go to "Audit - Machine Summary" and on the right side - "New Custom Field", I think.

  • hello rob.

    your idea sounds great. do you have more information about what your plans are? perhaps we can work both on that script for different vendors. i think it is a great idea for everyone in the community.

    kai.

  • Zippo, I've already passed the variables to the vbscript. That part was easy and thanks for the tip on creating custom feilds.

    Now I have two feilds, Warranty Type and Warranty Expiration.

    The file WARRANTY.DAT contains two lines of text, the first is the date and the second the Warranty type.

    I've got my script doing a get variable (file content) and storing it into #warrantyinfo#. This variable should contain two lines of text, how can I separte them? can I do a #warrantyinfo:1# and #warrantyinfo:2# to pick between the two lines of text?

    Kai, Once I've got it working I will be posting it to the Forums for all to use. (if I can figure out how to add a file) Since most of the vbs file was found online by another user (I left his info as reference) I think it would be best to share it with the community.

    The hardest part of doing the script is finding a URL where you can append the serial number and get a report.

    eg: support.dell.com/.../details

    The plan is to be able to pull a quarterly report of expiring warranites on systems for management.

  • Rob,

    use the application called "Update Warranty" www.updatewarranty.com/.../home 

     

    it'll create custom feilds on your agents in your Kaseya DB, then you can use views or reports or sql queries, 'Select * from vSystemInfoManual Where fieldName Like '%what you naed the feild%' AND fieldName < today'sdate;

     

    You could use a view, under "advanced agent data filter"     

    Warranty Expiration = > today

     

    it might be easier then trying to do some vbscript

    plus it's fairly cheap, $200 a year for 5K devices(agents). 

    If you resell any hardware this may be worth it to you. 

  • Perhaps this will help?

    www.updatewarranty.com/.../home

  • Nice, danrche. We posted at the same time :P

  • SMason

    Nice, danrche. We posted at the same time :P

    sigh, Great minds think alike. :b

  • The easiest solution would be to have your VBScript output two files - WARRANTY_1.DAT and WARRANTY_2.DAT then Kaseya can pull one variable from each. I would have Kaseya remove the two files once your Kaseya procedure is complete or just overwrite them each time it's run, if needed.

  • Thanks for the link but I can't use it.

    "Can UpdateWarranty update warranty expiration data for a Kaseya Cloud solution? Kaseya's API does not include a method to update Custom Fields. We may provide a solution in the future that reads the machines from your Kaseya Cloud and allows you to export the results to an Excel spreadsheet."

    I would have to tell you tho, even if I could use the application I would still want help in writing this script. I wasnt asking how to obtain warranty info, I'm trying to learn the Kaseya scripting language.

    Zippo, I'm hoping to find something a little cleaner than using two seperate files. Anyone have any ideas on that?

  • Rob

     

    Then secondly, how do I create a new colum in under the vSystemInfo.

     

    use the "Update System info" in the agent procedures, it'll allow you to input what ever you like into the fields you create, which can be done under the audit tab > machine summary 

     

    select a machine, and at the top of the page use the "New Custom Field" to create your new fields.

    Rob
    Using Kaseya's scripting I would pull the SQL data from vSystemInfo[Manufacturer] and vSystemInfo[System Serial Number] and store them into two variables in a script.

    use the getvariable and sql view data procedure step

    check out the doc's for this (click on the ? "help" function in your vsa). You should be able to do something like...

    vSystemInfo/system serial number/mach.groupID

    you could also use something like #vSystemInfo.System Serial Number#

     

    Rob
    How do I refer to the two individual items in the file, eg: line1. Line2.

    what does that file look like? Just those two lines or is it multiple text? 

     

     

  • Hi danrche,

    Thanks for those tidbits, I've already taken care of most of that the part i'm stuck on is the text file with variables.

    The text file has just two lines, first line is the date, second line is the warranty type.

    I want to read the lines in to variables and be able to pick between them.

    The file contents is only:

    01-21-2010

    HP Standard Warranty

  • Kaseya is going to read the full contents of the file in, currently I'm unaware of any sort of 'readline' abilities or any for loops for lopping through a file. BUT ... if you change your script up I think you could do this.

    Change your vbscript to accept input variables and then you could run the script with if statements to say if 1 then check warranty, else if 2 check expiration

    change the output to return, or echo (I think either will work if you're using a function over a sub)

    collect the results by launching the script with "agent procedures > execute shell command - get results to variable"  

    now you can just call that vbs twice in your Kscript using the cmd variables built-in your vbs to collect the 2 separate peices of info.

    From there, your variables should be easy to figure out when your setting up the procedure, plus you don't need to clean up any .dat files.

     

     

    If it helps, here's a sample of the arguments for a vbs:

     

     

    Set oArgs = WScript.Arguments

    iCount = WScript.Arguments.Count

    sCmdLine0 = WScript.Arguments.Item(0)

    iCmdLine1 = WScript.Arguments.Item(1)

    If iCount <> 2 Then

    WScript.Echo "The correct usage is 'App_Echo.vbs 'app' 'version''"

    ElseIf IsNumeric(iCmdLine1) <> True Then

    WScript.Echo "The version number should be of a numerical value with no '' or ."

    Else

    sfindapp sCmdLine0, iCmdLine1

    End IF

    sub sfindapp(sAPP, iVersion)
    <your code here>
    wscript.echo sResults
    end sub

     

     

     

  • Nice, I'll try that instead.

  • Let us know how it goes, Rob. I took a look at doing what you're doing but had issues with trying to scrape Dell's warranty website. I'll be interested to hear how you resolved it.