Kaseya Community

Script to pull the same file off of multiple pcs

  • Hello,

    I am trying to figure out how to pull a .ini file from multiple clients and have them combine into one single file.  THe file is in the same location on every machine.

    Anyone out there have any suggestions?

  • That is a little challenging.   Are all these computers on a common network?  How many computers do you need to pull this from?   How big is the .ini file?

    It would be simple to grab the file and upload it to the KServer, or if the .ini is small enough, even pop it into the body of an email, but to actually combine them, you would need to store the updated file in a common area.    Kaseya has good commands to PULL files from somewhere (I.e. GetURL), but nothing to PUT files outside of the KServer or a file copy to a location that is accessible.   Sadly we can't ATTACH a file to an email either.   You may be able to use a command line utility like mailsend (github.com/.../mailsend) to simply attach all the .ini files and then you manually combine them.

  • If all of the agents your're talking about are on the same network this is pretty easy.

    Create a file share on one of the agents so all the rest can write files to that share.

    create an agent procedure to do the following:

    getVariable("File Content", "c:\myfile.ini", "iniContents", ...)

    writeTextToFile("#iniContents#", "\\agentWithShare\SharedFolder", "false", ...)

  • We attempted this and it creates the file in the kworking folder on the machine but does not write the file to the network share.

    We copied your suggestion but it doesnt seem to want to write it to the share.

    Any thoughts?

  • ,

    If you're writing to a share, your procedure will need to authenticate to traverse the network.  Add the  useCredential step and ensure that the Agent > Set Credential for the machine where the file originates actually has access to write to the network share.  I would recommend starting very simply to make sure the basics are working before adding the complexity to the procedure.  For test purposes, create a procedure that simply copies a static file from the endpoint to the file share.  Be sure to include the useCredential step so the endpoint can traverse your network to the network share location (again, assuming the Agent > Set Credential account has access to the share).  If this works, then you know the endpoint and the file share can communicate.  Once that's working, edit the procedure to include the getVariable and writeTexttoFile steps recommended by .

  • To allow completely annoymous access to a share, you need to add these two users / groups:

    - Everyone