Kaseya Community

Powershell Runs Locally but not through Agent Procedure

This question is not answered

My my! 

So I have created the following procedure to call a powershell file and execute it but it's being wonky. The script has a line to append to a file on a server so I'm thinking that Running as System doesn't have the access it needs to get to this network location (although the location specified is open to domain users). Guessing Kaseya's system doesn't count as a domain user though! 

We do have a network account called kaseya-service so I'm wondering if there's a way I can execute the command as that and hopefully then it will be able to append what it needs to the CSV in the location. 

This is what I have: 

Please advise! 

All Replies
  • 1. SYSTEM is the local computer account... you can add a preceding "Use Agent Credential" or "Impersonate User" step for network locations. Then switch the shell command step to Execute as User to run as that credential.

    2. PowerShell execution policy will be per user, included SYSTEM. You can use "-ExecutionPolicy Bypass" parameter in your shell command or switch to the executePowerShell step which includes it for you

  • 3. Also consider using executeShellCommandToVariable() then write the output to procedure log for debugging... DEBUG: #global:cmdresults#

  • Do you have to wrap the -ExecutionPolicy Bypass in "" or is that just for documentation ?

  • Hi

    This is not what you ask for but I hade probems running PS scripts through kaseya like that so I ended up just sending the ps file to the server and ran it. and when done delete it.

    write file



  • Hi,

    1) Make backup of je KSubscribers database.

    2) Could you please follow the below steps:

    * look for <Drive>:\Kaseya\DBInstall\AgentProcedures\script\loadSubAgentProcs.sql in your kaseya server

    * Open file in SQL management Studio - check that you have the "ksubscribers" database selected - click execute

    This will create a job in the database that will re-load the kaseya sub procedures.

    As Always this is at your own risk :)

    Had the same issue. This was i got from kaseya support. And fix it with me.

    Hope it will help you.