Kaseya Community

Monitor Details Script

  • Hi,

     

    I have created script for getting monitor details like Make, Serials No.,  Model & Date of Mfg.

     

    Q is how to update the vb script output to Custom Fields created in kaseya 6.0.1.0.

     

    Thanks

     

    M I Farook

  • you will first need to pipe the results out of your vb script to something like #vAgentConfiguration.AgentTempDir#\vbsoutput.txt then read this into a variable and then there is a step in the agent procedures called update system info. You will need to create the field first under any agent but then you can update from a script.

  • Thanks for the response.

    Require some more help from you, Output file content is below, How can i create "Update System Info"

    I had created Custom Fields like "Monitor Make", "Monitor Sr. No." "Monitor Model" & "Monitor DOM".

    _____________________________________________________

    Microsoft (R) Windows Script Host Version 5.6

    Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

    Make:- HWP

    Serial No:- CNT00751PK

    Model:- HP v185e

    D.O.M:- 2/2010

    _____________________________________________________

    Request you to can you give examples to update the system info.

  • Most of those can also be found in the Database Views so you might not have to use a Vbscript. Do search for them in help file if you don know what I'm talking about Smile

    Also the Get WMI Variable command is very handy for digging that type of info out, your Vbscript probably uses the WMI Win32_ComputerSystem and/or Win32_ComputerSystemProduct Classes to get to those so you could potentially make pure Kaseya procedure without the need to upload files or read text files into variables...

  • Farook, are you able to post up your vb code and then we can translate it to wmi query kaseya code for you.

  • strComputer="."
    dim strarrRawEDID()
    intMonitorCount=0
    Const HKLM = &H80000002
    Set oRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "/root/default:StdRegProv")
    sBaseKey = "SYSTEM\CurrentControlSet\Enum\DISPLAY\"

    iRC = oRegistry.EnumKey(HKLM, sBaseKey, arSubKeys)
    For Each sKey In arSubKeys
        sBaseKey2 = sBaseKey & sKey & "\"
        iRC2 = oRegistry.EnumKey(HKLM, sBaseKey2, arSubKeys2)
        For Each sKey2 In arSubKeys2
            oRegistry.GetMultiStringValue HKLM, sBaseKey2 & sKey2 & "\", "HardwareID", sValue
            for tmpctr=0 to ubound(svalue)
                if lcase(left(svalue(tmpctr),8))="monitor\" then
    sBaseKey3 = sBaseKey2 & sKey2 & "\"
    iRC3 = oRegistry.EnumKey(HKLM, sBaseKey3, arSubKeys3)
    For Each sKey3 In arSubKeys3
    if skey3="Control" then

    oRegistry.GetBinaryValue HKLM, sbasekey3 & "Device Parameters\", "EDID", arrintEDID
                 if vartype(arrintedid) <> 8204 then
    strRawEDID="EDID Not Available"
    else
    for each bytevalue in arrintedid
    strRawEDID=strRawEDID & chr(bytevalue)
    next
    end if

    redim preserve strarrRawEDID(intMonitorCount)
    strarrRawEDID(intMonitorCount)=strRawEDID
    intMonitorCount=intMonitorCount+1
    end if
    next
                end if
            next
           
        Next
    Next
    Dim arrMonitorInfo()
    redim arrMonitorInfo(intMonitorCount-1,5)
    dim location(3)
    for tmpctr=0 to intMonitorCount-1
    if strarrRawEDID(tmpctr) <> "EDID Not Available" then
    location(0)=mid(strarrRawEDID(tmpctr),&H36+1,18)
    location(1)=mid(strarrRawEDID(tmpctr),&H48+1,18)
    location(2)=mid(strarrRawEDID(tmpctr),&H5a+1,18)
    location(3)=mid(strarrRawEDID(tmpctr),&H6c+1,18)
       

    strSerFind=chr(&H00) & chr(&H00) & chr(&H00) & chr(&Hff)

    strMdlFind=chr(&H00) & chr(&H00) & chr(&H00) & chr(&Hfc)
       
    intSerFoundAt=-1
    intMdlFoundAt=-1
    for findit = 0 to 3
    if instr(location(findit),strSerFind)>0 then
    intSerFoundAt=findit
    end if
    if instr(location(findit),strMdlFind)>0 then
    intMdlFoundAt=findit
    end if
    next


    if intSerFoundAt<>-1 then
    tmp=right(location(intSerFoundAt),14)
    if instr(tmp,chr(&H0a))>0 then
    tmpser=trim(left(tmp,instr(tmp,chr(&H0a))-1))
    else
    tmpser=trim(tmp)
    end if
    If left(tmpser,1)=chr(0) then tmpser=right(tmpser,len(tmpser)-1)
    else
    tmpser="Serial Number Not Found in EDID data"
    end if

    If intMdlFoundAt<>-1 then
    tmp=right(location(intMdlFoundAt),14)
    if instr(tmp,chr(&H0a))>0 then
    tmpmdl=trim(left(tmp,instr(tmp,chr(&H0a))-1))
    else
    tmpmdl=trim(tmp)
    end if
    If left(tmpmdl,1)=chr(0) then tmpmdl=right(tmpmdl,len(tmpmdl)-1)
    else
    tmpmdl="Model Descriptor Not Found in EDID data"
    end if

    tmpmfgweek=asc(mid(strarrRawEDID(tmpctr),&H10+1,1))

    tmpmfgyear=(asc(mid(strarrRawEDID(tmpctr),&H11+1,1)))+1990

    tmpmdt=month(dateadd("ww",tmpmfgweek,datevalue("1/1/" & tmpmfgyear))) & "/" & tmpmfgyear

    tmpEDIDMajorVer=asc(mid(strarrRawEDID(tmpctr),&H12+1,1))

    tmpEDIDRev=asc(mid(strarrRawEDID(tmpctr),&H13+1,1))

    tmpver=chr(48+tmpEDIDMajorVer) & "." & chr(48+tmpEDIDRev)

    tmpEDIDMfg=mid(strarrRawEDID(tmpctr),&H08+1,2)
    Char1=0 : Char2=0 : Char3=0
    Byte1=asc(left(tmpEDIDMfg,1))
    Byte2=asc(right(tmpEDIDMfg,1))
    If (Byte1 and 64) > 0 then Char1=Char1+16
    If (Byte1 and 32) > 0 then Char1=Char1+8
    If (Byte1 and 16) > 0 then Char1=Char1+4
    if (Byte1 and 8) > 0 then Char1=Char1+2
    if (Byte1 and 4) > 0 then Char1=Char1+1

    If (Byte1 and 2) > 0 then Char2=Char2+16
    if (Byte1 and 1) > 0 then Char2=Char2+8
    If (Byte2 and 128) > 0 then Char2=Char2+4
    if (Byte2 and 64) > 0 then Char2=Char2+2
    if (Byte2 and 32) > 0 then Char2=Char2+1

    Char3=Char3+(Byte2 and 16)
    Char3=Char3+(Byte2 and 8)
    Char3=Char3+(Byte2 and 4)
    Char3=Char3+(Byte2 and 2)
    Char3=Char3+(Byte2 and 1)
    tmpmfg=chr(Char1+64) & chr(Char2+64) & chr(Char3+64)

    tmpEDIDDev1=hex(asc(mid(strarrRawEDID(tmpctr),&H0a+1,1)))
    tmpEDIDDev2=hex(asc(mid(strarrRawEDID(tmpctr),&H0b+1,1)))
    if len(tmpEDIDDev1)=1 then tmpEDIDDev1="0" & tmpEDIDDev1
    if len(tmpEDIDDev2)=1 then tmpEDIDDev2="0" & tmpEDIDDev2
    tmpdev=tmpEDIDDev2 & tmpEDIDDev1

    arrMonitorInfo(tmpctr,0)=tmpmfg
    arrMonitorInfo(tmpctr,1)=tmpdev
    arrMonitorInfo(tmpctr,2)=tmpmdt
    arrMonitorInfo(tmpctr,3)=tmpser
    arrMonitorInfo(tmpctr,4)=tmpmdl
    arrMonitorInfo(tmpctr,5)=tmpver
    end if
    next
    for tmpctr=0 to intMonitorCount-1
    WScript.echo Make & "Make:- " & arrMonitorInfo(tmpctr,0)
    wscript.echo Serial & "Serial No:- " & arrMonitorInfo(tmpctr,3)
    wscript.echo Model & "Model:- " & arrMonitorInfo(tmpctr,4)
    wscript.echo DOM & "D.O.M:- " & arrMonitorInfo(tmpctr,2)
    next

  • i c you get your info out of the registry then, the only piece that would be difficult to replicate in a pure Kaseya script is the Date as it gets formatted in your VBscript and the values you would get out of WMI and the registry are raw...

  • Except Date how to replicate other data into K- Script,

    Can you explain.