Kaseya Community

Script folder, VSA Shared Files Cleanup

This question has suggested answer(s)

I inherited this VSA years ago, and love to go through and clean up some of these areas.  I think I am looking for a SQL query to give me:

1) A list of VSAShareFiles that aren't associated with a script.

2) A list of user made scripts with the last time the agent procedure was run.

I have started but... if anyone wants to help that would be cool

All Replies
  • Bumping this, as our VSASharedFiles has become a morass of (possibly) orphaned files over the dozen or so years we've been running as a Kaseya shop...

  • Hi guys, we have an issue at the moment with agent procedures completely failing to run that has been going on for a week. Some (but by no means the majority of these) are caused by procedures scheduled against machines that have become orphaned (script is scheduled to run but never runs). In theory, cancelling these scripts and reapplying them to affected machines can gain you some ground but we are seeing mixed results.

    A query to identify machines with orphaned scripts is below:-

    select ocs.rowdesc as scriptname, ocs.scriptid, mnt.displayname as agentname, ocs.agentguid, ei.scheduledDate, ei.startedDate, ei.inProcess, sa.execscriptTime

    from dbo.orgcalendarschedule ocs

    join hermes.eventinstance ei on ocs.id = ei.orgcalendarscheduleId

    join dbo.machnametab mnt on ocs.agentguid = mnt.agentguid

    left join dbo.scriptassignment sa on ei.eventinstanceID = sa.eventinstanceID

    where ei.inProcess = 1

    and sa.execscriptTime is null

    order by scriptname

    Hope that helps!

  • I haven't had a chance to dig into it yet, but it's obviously possible.  If you go to view the "managed files" from the agent procedure tab, there is an option you can check to "Show unused files", and checking that box adds and "unused" label to the left of the file names for ones that aren't used.

  • Awesome I too thinking to clean this 10+ years of junk from our VSA. I will also start digging this.

    Also will love to have some maintenance queries for VSA db fi anyone can share.

    TIA all. 

    [edited by: Rajeev Sharma at 4:08 AM (GMT -7) on Oct 26, 2018]
  • That was correct clue. here it is

    -Go to Agent Procedures

    -Under file transfer click on Distribute File

    -On right side pan above Distribute Tab click on "Manage Files" hiperlink

    -Select Shared

    -In the bottom of new popped up window showing list of files folder, there is check box named "Show unused files not referenced by any scripts ...."

    -Once you check that box it will take a while and you will see all orphaned files in list tagged as "unused"

    Just delete what ever you like.

    Thanks all.