Kaseya Community

Reporting to the same file from multiple agents

  • Is it possible to execute agent procedure (powershell script) for multiple machines and store all results into the same file.

  • Sure you can.. Create you a file share that the PC's have access to.. A log file persay.. Then have in your procedure to append to that log file the information you get from your end points

  • Davis, We are report from completely different clients and networks that are not related or connected. If it is possible in that case?

    Thank you

  • We used to be able to use the getfile command with a relative path  e.g. ../../yourfiles/yourfilename.txt .. but I will test this for you again as the function may have been removed.

    What it allowed you to do was run a script on any machine and save all  files from any machine all into the same folder on the VSA.

    So not quite what you want but 1/2 way.

    The 2nd bit is a simple vb script that when run on the VSA reads each file individually and appends the content from each to the single specific file you want.

    I've got a working example of this so let me dig it out


  • Paul.

    Writing file in a single folder on vsa might be an interesting for me for some situations and if there is no other solution for my request  it could be an option as well. I'm interested to see how you do it. Thank you

  • Yes that is possible.. you just have to use a different text file for the different clients.

  • Use the following VB Script to combine files (obviously tweak as needed) in a single directory on VSA.  you can then do whatever is needed with end combined file (we actually use SSIS job to import data into SQL at that point).

    Const ForReading = 1

    Set objFSO = CreateObject("Scripting.FileSystemObject")

    Set objOutputFile = objFSO.CreateTextFile("C:\lloyd\UserListCombined.csv")

    strComputer = "."

    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

    Set FileList = objWMIService.ExecQuery _

       ("ASSOCIATORS OF {Win32_Directory.Name='C:\Lloyd\ClientAD} Where " _

           & "ResultClass = CIM_DataFile")

    For Each objFile In FileList

       Set objTextFile = objFSO.OpenTextFile(objFile.Name, ForReading)

       strText = objTextFile.ReadAll


    Set objFSOdel = CreateObject("Scripting.FileSystemObject")

    objFSOdel.DeleteFile objFile.Name,TRUE

    Set objFSOdel = Nothing

       objOutputFile.WriteLine strText



  • How it is possible to save it to a file stored on VSA? Do you know how to do that? Thanks

  • Chris , thank you for that. Anyone know how to save data in a file stored on VSA directly when you run procedure/powershell on client.

  • So just checked and you can no longer use a relative path in GetFile

    But Getfile saves files to the following folder on your VSA


    Where 140208802855838 is the agentguid of the machine

    So create the text files you need on each machine and use the getfile command to save them to the VSA.

    I would usually also name the file so it also includes the agentguid in the file name

    e.g.  140208802855838_MyFileName.txt

    Thats Part 1 , i.e. it has created and saved the files to the VSA

    Part 2 is to create a script that you run on your VSA that searches and moves all these files to a single folder

    I'd typically move then all to a folder in the path below , as this is a location Kaseya has provided where user files can be saved , and is also accessible using the Agent Procedure "Managed Files" menu


    So you now end up with all you individual files moved to e.g.


    Part 3 is as AL the files are now in 1 folder then use something like Chris's vbscript to read each file and consolidate into a single file


  •  Thank you for this short tutorials. It would be better to have automated way to do this kind of stuff. For example store file (getfile) directly to one file on VSA so the endpoints can directly write to that file , not to multiple separate files. Second, there is no attach file option in VSA, you must use powershell or other tools. In this case you can't use VSA system variables (#vMachine.machName# | #vMachine.groupName# | #vagentconfiguration.currentuser#  etc..) that I often use in reporting. Let's hope Kaseya will implement this kind of stuff.

    Small corrections
    [edited by: szelic at 6:11 AM (GMT -7) on Sep 1, 2017]
  • HI Szelic

    There is actually another command you can use to save files directly to the VSA into a single folder.

    It's called "TransferFile"   but is a bit trickier to use as you need to specify the destination machine name as "e.g. "vsa.group.org" , and it still means multiple files.

    So this will work as long as you never rename your VSA as it appears in Kaseya

    Using this step you can transfer the file to pretty much any folder on the VSA

    Not sure what you mean re Attach File

    Can you give me an example and how you might use this.


  •  I was thinking of attaching a file when sending an email in agent procedure. You don't have that option in VSA. You must use other tools. I will test all those steps you mentioned and see what works the best for me. Thank you

  • , run the script, bring the file back into the VSA as a variable and write it out using a tag of some sort to the agent procedure log.  (I like using $Tagname$).   Then run a basic log report and filter on that tag, and dump it to Excel where you can probably manipulate it further.

  • The process is quite easy

    In your script just add a step called "Transfer File"

    You will need to specify the source file , the Machine you want to transfer to e.g. your VSA , and a destination as an absolute path on the VSA where you want to save the file(s)

    So as an example :

    Source could be c:\kworking\MyFile.text

    Machine would be vsa.group.org

    Destination could be C:\Kaseya\WebPages\ManagedFiles\VSASharedFiles\myfiles\

    To make each filename individual I'd actually use the following as the destination by adding the actual machine name as part of the file name

    You could also add a random number or date_time to the filename as well , allowing you also to have multiple files from the same machine



    I'll Post an example script in a minute


    Added a few extra bits and fixed a typo
    [edited by: Paul Haaker at 2:08 PM (GMT -7) on Sep 5, 2017]