Kaseya Community

writeFileFromAgent - clear cached file from kserver?

  • How do I clear a file from the kserver cache so this method actually grabs an updated file from the source? Is there a workaround?

    PS, nowhere is it documented that writeFileFromAgent caches any file it grabs from the kserver, which is very annoying when I'm making changes to a powershell script that is being delivered via this method. I'm actually going to use this to push a file that gets nightly updates, so making this work is critical to my use case.

  • Why don't you use the "writefile" command instead and store the files on the VSA

    My understanding of this command  is it does a check of the file each time and if it has changed on the VSA it will overwrite any previous version saved to the endpoint

    help.kaseya.com/.../9050000

  • Paul,

    The file in question is being updatied nightly, so using writeFile from the kserver isn't convenient for this workflow.

    In my testing, the script makes no check if the file requested by writeFileFromAgent has changed, only if the file exists in the kserver.  

    I appreciate your response, but this does not answer my initial question of clearing the cache.

  • I've tried using GetFile but I can't store the files outside of the agent's private folder?

    I tried using info from here but it fails with an error. community.kaseya.com/.../672.aspx

  • I think they took away the ability to do save to relative paths this some time ago.  A shame as it was really handy to consolidate output files.

  • There is still a way using the transferfile command where you can take individual files from agent endpoints and save them all to a single folder on the VSA  .e.g. save them all to a folder within the ../ManagedFiles/VSASharedFiles/.... location on the VSA

    This then means all those files are then also accessible via agent procedures to be re-written out again to endpoints or simply accessed via the VSA UI in the "Managed Files" menu of Agent Procedures

  • Paul, I'm confused as to how this would work. How do I run an agent procedure as the VSA?

  • What I'm suggesting is an alternative way to "Save Files to a Relative Path " which we could do in the past using the getfile command , instead you can use the transferfile command

    The transferfile command take 3 properties

    1) the full machine name of the machine you want to transfer the file to e.g. "myvsa.group.org"

    2) The local path/filename of the source file you want to transfer e.g. "#agentdir#\MyFile.txt"

    3) The fullpath/Filename on the destination machine e.g. "C:\Kaseya\WebPages\ManagedFiles\VSASharedFiles\myfiles\#vMachine.Machine_GroupID#_MyFile.txt"

    In 1) I have specified the VSA as the destination machine ( this assumes you have a Kaseya Agent installed on the VSA)

    The source file in 2) can be any file on the local machine.

    And 3) is where we specify where on the destination machine we want the file transferred to and the name we want to give it.

    As these files will come from multiple machines , i.e. every machine you run the script on , it’s important that when you transfer the file you make the file name Unique .. hence I added a prefix being the actual Full Kaseya Machine name to the file name

    So running a script like the above on multiple machines results in the file transferred from each machine ending up on the VSA all in the same folder

    The reason I choose to save them in the “C:\Kaseya\WebPages\ManagedFiles\VSASharedFiles….” Path is all these files now reside on the VSA in a folder that is now also accessible to other agent procedures.using the writefile command