Kaseya Community

Read Text File, Write System Info

  • I'm trying to do something here that is eluding me...

    I want to run a program (EDD.exe), which has to be run in an Administrative Command Prompt in order to be able to redirect its output to a text file.
    That part I have working
    Once it's created the text file, I then need to read that text file and see if it contains "PGP" or "TrueCrypt", and if it does, write a SystemInfo value to indicate these are present - which is not working.
    I get a FAILED Then in step 2 (line 2)
    What do I need to change to get this working the way I need?
    ");"><Body description="">
    ");"><Statement name="ExecuteShellCommand" continueOnFail="false">
    <Parameter xsi:type="StringParameter" name="Command" value="powershell.exe -Command "Start-Process C:\kaseya\edd.cmd -Verb RunAs""/>
    <Parameter xsi:type="EnumParameter" name="ExecuteAccount" value="User"/>
    <Parameter xsi:type="BooleanParameter" name="Is64Bit" value="False"/>
    </Statement>
    ");"><If description="">
    ");"><Condition name="TestFileInDirectory">
    <Parameter xsi:type="StringParameter" name="Path" value="C:\Kaseya\edd.txt"/>
    <Parameter xsi:type="EnumParameter" name="Condition" value="Contains"/>
    <Parameter xsi:type="StringParameter" name="Value" value="PGP"/>
    </Condition>
    ");"><Then>
    ");"><Statement name="UpdateSystemInfo" continueOnFail="false">
    <Parameter xsi:type="StringParameter" name="ColumnName" value="PGP:"/>
    <Parameter xsi:type="StringParameter" name="Value" value="Yes"/>
    </Statement>
    ");"><If description="">
    ");"><Condition name="TestFileInDirectory">
    <Parameter xsi:type="StringParameter" name="Path" value="C:\Kaseya\edd.txt"/>
    <Parameter xsi:type="EnumParameter" name="Condition" value="Contains"/>
    <Parameter xsi:type="StringParameter" name="Value" value="TrueCrypt"/>
    </Condition>
    ");"><Then>
    ");"><Statement name="UpdateSystemInfo" continueOnFail="false">
    <Parameter xsi:type="StringParameter" name="ColumnName" value="TrueCrypt"/>
    <Parameter xsi:type="StringParameter" name="Value" value="Yes"/>
    </Statement>
    </Then>
    </If>
    </Then>
    </If>
    </Body>
    </Procedure>
    </ScriptExport>
  • Hi,

    The export you've pasted seems corrupt, however I'm getting the sense that the CMD you're running isn't happening. How is it being written to c:\kaseya?

    I'd be happy to provide more help if you could attach the XML file, and even better the CMD file as well?

  • Hello csoska,

    How about a single Powershell step (ExecutePowerShell) as below?

    (& "edd.exe" | Out-String -Stream | sls -Pattern "(PGP)|(TrueCrypt)").Matches.Count

    And then a step where you check if the variable is greater than 0?

    This way you don't have even to output to file, process the file etc... all done in one quick step in

    memory.

    Best Regards

  • I don't see a way to attach anything, but the .CMD does execute exactly as intended.
    The .CMD and the application are distributed via Kaseya separately.

  • The EDD.exe application is very peculiar - if it is not executed in an administrative command prompt some functionality is lost. I also want to generate the text file for some of the other information in creates

  • Click on Use rich formatting then select the Options tab. You should see a file attachment option.

  • Hello csoska,

    You can execute edd.exe as Administrator in Powershell as much as the normal Command.

    If you really want to output the result of edd.exe to a file instead of doing all in memory as I was suggesting previously you can use this one:

    (& 'edd.exe' > d:\youroutputfile.txt) ; (sls -Path 'd:\youroutputfile.txt' -Pattern '(PGP)|(TrueCrypt)').Matches.Count

    Read as usual the #global:psresult# and check if it's greater than 0 with a kaseya IF CheckVariable step.

    Best Regards