Kaseya Community

Get variable from a text file.

  • Hello All,

    If someone here can help, it would be a life saver.  I've created a custom field in "Machine Summery" under the Audit tab and need to input a variable to it.  I've been able to input text to a variable, through Kaseya, and input that variable into a field, but it grabs everything in the text file.

    For example, I have a custom field for Password Complexity and want either a 1 or 0 there.  I'm assuming I need to run a VB script to find line PasswordComplexity and get the number after the = , but I have no idea how to do it.

    [System Access]
    MinimumPasswordAge = 1
    MaximumPasswordAge = 180
    MinimumPasswordLength = 8
    PasswordComplexity = 1
    PasswordHistorySize = 24
    LockoutBadCount = 10
    ResetLockoutCount = 30
    LockoutDuration = 30

    I've searched and I think this is close to what I need, but I'm just not sure.

    Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4

    Dim source, target
    source = "c:\source.txt"
    target = "c:\target.txt"

    Dim fso, f, f2
    Const ForReading = 1, ForWriting = 2

    Set fso = CreateObject("Scripting.FileSystemObject")
    If fso.FileExists(source) Then
    Dim inputLine, outputLine
    Set f = fso.OpenTextFile(source, ForReading, False)
    Set f2 = fso.OpenTextFile(target, ForWriting, True)
    While Not f.AtEndOfStream
    inputLine= f.ReadLine

    ' analyze inputLine in here using String manipulation Left(), Mid(), Right(), Split(), Instr() etc...

    ' build outputLine so it looks as desired...

    f2.WriteLine outputLine
    Set f2 = Nothing
    Set f = Nothing
    MsgBox "Done"
    MsgBox source, vbOKOnly, "Source File Not Found"
    End If
    Set fso = Nothing

  • community.kaseya.com/.../2190.aspx

  • Thank you so much for pointing me in the right direction.

    for /F "tokens=2 delims==" %a in ('findstr "PasswordComplexity" "Target_Doc.txt"') do echo %a >> C:\temp\tempout.txt

  • Hi nbeach,

    An alternative command to do this would be:

    type target_doc.txt | find "PasswordComplexity" >> c:\temp\temout.txt

    Just as an alternative. I see someone on that post had problems with the findstr command.