I've written a simple Agent Procedure that uses the writeFileFromAgent command to copy a config (txt) file from the Kaseya server to the host machine that the procedure runs on.
It grabs the machine name, then goes to a directory on the Kaseya server, matches the machine name to the folder, then copies over the config file to a location on the host machine. This seemed to work well with no problems
However, as a test, when I removed the config file (from the Kaseya server) the procedure still ran with no errors. It somehow copied the missing config file to the host machine.
I found that there is another directory that it is grabbing the config file from, not the specified path that I have in the script of the procedure.
Rather than C:\Config\<Agent Machine Name>\file.txt
It copies an older version from D:\Kaseya\UserProfiles\<Agent GUID>\filetransfer\file.txt
Am I missing something? I cant work out why it is looking at the wrong directory, despite my script specifying the path. Even the logs say that it is copying from the correct path....
If you are trying to move the file FROM the KServer TO an Agent, use the writeFile step. writeFileFromAgent copies a file from a specifed agent to the agent executing the procedure (via the KServer).
The writeFile step will compare the file (via Hash) from the source (Kserver) against that on the agent and write the file only if it is missing on the target OR the hash does not match. This can help reduce overhead - there's often no need to move the file if the target machine already has the most current version (which is what differentiates writeFile from copyFile).
If that doesn't fix the problem, post your procedure and the community can take a stab at helping troubleshoot.
Thanks for that, I'll give that a try. Does the writeFile step only look at a pre-determined directory on the KServer though?
I had an issue with this one before where I tried to get it to copy 'file.txt' from C:\temp (on the KServer to a host machine) but it just appeneded 'C:\temp\file.txt' to D:\Kaseya\WebPages\ManagedFiles\
ie. Rather than look in C:\temp for 'file.txt' it tried to get a file called 'C:\temp\file.txt' from D:\Kaseya\WebPages\ManagedFiles\ and it just threw an error in the logs
As long as the info in those config files isn't something that would be a security issue if they got out, I would probably look at putting them on a webserver somewhere (or maybe even just in a separate published directory on your kaseya server that doesn't require authentication?), and using the getUrl function.
Otherwise if the config file is simple enough that you can "build" it on the fly within your procedure then use the writeTextToFile to dynamically build it.
The config file will be unique to the machine that the procedure runs on. That is, we will have multiple unique config files that get pushed to the corresponding machines. The idea was to have a directory on the KServer that had individual folders matching the machine names. When the procedure runs, it matches the machine name to the directory, grabs the file and pushes it to the machine. This allows us to update the config files from a windows directory rather than having a unique procedure to run on each machine.