Kaseya Community

gpresult output to file and email me

  • Id like to script gpresult on some workstations, have it output to a file and then email me the results. (Soo much easier than asking a user to perform this.)

    I took the Ping Script 1 and edited it for this purpose. What I have is:
    Step 1 - Get Variable. Get the agent temp dir. Set to #agentTempDir#
    Step 2 - Execute Shell Command. Command = gpresult.exe >> "#agentTempDir#\gpresultoutput.txt".
    Step 3 - Get Variable. File Content. File name = #agentTempDir#\gpresultoutput.txt. Variable = #gpresultoutput#
    Step 4 - Send Email. To me. Body = #gpresultoutput#

    The script runs fine without error. When gpresult runs, it does create the output file, but the file is empty, and then it emails me the empty file. So, its as if the ">>" operator isnt actually pushing any data into the output file.

    In a perfect world, Id also like gpresult to run with the /v flag, but Im not sure if the Kaseya script editor can understand flags.

    Any idea whats causing this not to work properly?

    Legacy Forum Name: gpresult output to file and email me,
    Legacy Posted By Username: mariaworld
  • I was having the same problem with the script as you were until I changed some things:

    * In Step 2: the output file was blank until I executed the script as the user instead of system.
    * Also the /v will work as follows: gpresult.exe -v >> "#agentTempDir#\gpresultoutput.txt".

    I hope this helps!

    --Jason

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: jcoleman
  • Thanks. The Execute Shell command was running as User. For giggles, I switched it to system, tested it, and switched it back. Still no go. I get a blank output file.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: mariaworld
  • The solution was that the Kaseya Helper Agent was not running on the workstations I was running the script against. I had to start KaUsrTsk.exe, then the script executed fine.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: mariaworld