Kaseya Community

Combining single and double quotes

  • Hi, im trying to run this powershell, but Kaseya keeps butchering the quotes. Its a combination of single and double quotes. What would be the correct way to run this powerhshell?

    Get-WmiObject win32_useraccount -Filter "name='#vAgentConfiguration.currentUser#'" | select-object sid

  • Hi,

    You can use this other one and run it with executeshellcommand.

    wmic useraccount where(name='#vAgentConfiguration.currentUser#') get sid

  • The problem with this is that it outputs the command with trailing white spaces. I can create a full batch to remove the trailing white spaces, but i really need this working in a single command

    "S-1-5-21-1234567899-123456783-123456782-1234  "

  • Though can always use this:

    (Get-Content #vAgentConfiguration.agentTempDir#\SID.txt) -replace '\s' | Set-Content #vAgentConfiguration.agentTempDir#\SID.txt

  • The space is a byproduct of how PoSh expands variables and concatenates strings.

    I would suggest:


    will give you eactly what you're looking for

  • You can use a trick i've learned in this forum:

    Use SQLRead and create an XML like this one:

    <?xml version="1.0" encoding="utf-8" ?>


        <queryDef label="RemoveSpaceGlobalCMD" sql="Select top 1 rtrim('#global:cmdresults#') as Result" />


    [edited by: rivSeSys at 1:42 AM (GMT -8) on Jan 11, 2019]