Kaseya Community

Issue trying to fill in Custom field using Powershell command in Agent Procedure

  • I created this script and while it runs successfully, it is not populating the Custom Field I created.  Any ideas?

    If isUserLoggedin(" ")

          executePowershellCommand64bitUser ("", "Test-Path "C:\Users\$env:Username\AppData\Local\Google\Chrome\User Data\Default\Extensions\hdokiejnpimakedhajhdlcegeplioahd"", true, "All Operating Systems","Halt on Fail")

           pauseProcedure (15, "All Operating Systems", Halt on Fail")
           If checkVar ("global:psresult") is Equal To "True"
               updateSystemInfo("LastPass","Installed","All Windows Operating Systems", Halt on Fail")

  • Change "is Equal to" for "Contains"

  • Still fails with contains....getting error of Check for powershell failed!

  • Change the poweshell command and put this one:

    Test-Path 'C:\Users\#vmachine.loginname#\AppData\Local\Google\Chrome\User Data\Default\Extensions\hdokiejnpimakedhajhdlcegeplioahd'

  • Since lastpass can be installed for all users, or just a single user, your test for it's installation would probably be best served by getting the value of: HKLM\SOFTWARE\LastPass\InstallUser  which will contain the login name of the user that has it installed only for themselves or "All" for installed for everyone,

  • Unfortunately only the extension and not the program itself is installed so I can't check the HKLM key

  • Got the same error of check for powershell failed

  • I've typically always been recommended to use PS1 files for most stuff. Put your command into a PS1 file then have Kaseya run it. I'm not sure that it would export the results to the global variable like in your  procedure. You can have your PS1 file export the results to a log file and then use Kaseya to create your variable like that.

    I've had a similar simple little command fail when I plugged it in directly like you have. Opened a ticket for it, failed for Kaseya techs too. Their solution was the PS1 file.

  • That was my next step.  Would be nice if it actually worked as intended

  • Your checkvar command have the #s around global:PSresult.

    On another note I always use "ExecuteShellCommandToVariable", which returns any output to #global:cmdresults".

    So you should be able to just run: powershell.exe  Test-Path "C:\Users\$env:Username\AppData\Local\Google\Chrome\User Data\Default\Extensions\hdokiejnpimakedhajhdlcegeplioahd"

  • , 2 things.  First #stephen is correct, you forgot the # symbols around the global:PSresult, so if you add those, it might work.  Second,  to help in troubleshooting, just write that result to your Agent procedure log so you can make sure that you are getting the result you want.