Kaseya Community

Changes in procedures (use of quotes) in .27 build or were things previously working that shouldn't have worked?

  • Since making the upgrade to .27 I'm seeing some changes to how procedures are handling quotes that I've either not encountered before or which are different than how everything has operated in previous builds

    Given variables defined as:  #global:path# ::= "C:\Some Folder\Level1\"  and #global:file# ::= "The File.txt"

    The following works as expected:

    if testfile(""#global:path##global:file#"")  Exists OR if testfile("'#global:path##global:file#'") exists

    But this will error:

      GetFile(""#global:path##gloval:file#"",....)  or GetFile("'#global:path##global:file#'",...)

    While this works:

      GetFile("#global:path##global:file#",...)  or GetFile(""C:\Some Path\Level1\Some File.txt"",....)

    In all cases, the outermost pair of quotes are generated by the procedure itself.

    --- Additionally ---

    Since PowerShell commands are invoked as (PowerShell -c "the commands")  the guiding principle should be that single quotes need to be used inside of the command otherwise the commands get broken and fail.  But this too is not being consistent since ("'c:\some path\poshscript.ps1' *>> 'c:\another path\capture.txt'") will fail while (""c:\some path\poshscript.ps1" *>> "c:\another path\capture.txt"") will work.

    So what is the consistent & expected behavior with quotes in commands because I now have code that's been working for years that's requiring that I go back in and re-write it, testing all different combinations of quotes, in order to return the code back to operational form.

    What's changed and is the behavior now the correct behavior and all of the stuff that worked in the past was slipping by somehow?

    I've checked the documentation and I'm unable to find where the use of quotes in the commands is clearly outlined as when they are required vs. when they will cause a failure and if they can/should be used, how they should be used.

    I'm really interested in what others have to say on this topic.

  • Hello Pedro,

    I didn't see many changes about handling qoutes at the moment all my procedure running fine, but it depend on what PowerShell statement you use or how you setup the variable.

    I don't use double qoutes anymore because it's consistent when you need to use them and when not. I always use set a constant value with the lines / variable and push that to powershell exe.

    Wish Kaseya could generate more documentation about this aswell because it's sometimes hard to troubleshoot...

    Hope this get you some insides, otherwise you can always message me on discord or here ;)

  • The PowerShell quote inconsistency aside (note that I show a case where the single quotes will fail and you're forced to use double quotes)  the use of quotes in getfile() and writefile() failing when using variables has been confirmed as a bug.

  • Pedro do you use getvariable to set the string location? Because I always use that one a don't have a problem with it.