Does anyone know the proper syntax for Powershell custom inventory rules in 5.5? I haven't had a ton of time to investigate it. I've added the cmd.exe /c to the majority of my "ShellCommandTextReturn" rules and that has resolved them. Just trying to get this resolved before I upgrade here in a couple of months.

This worked in 5.4, but no longer with the 5.5 agent.

ShellCommandTextReturn(powershell Get-WmiObject Win32_ComputerSystemProduct | Select Version)

I've tried this with 5.5, but it returned no results. I'm not seeing errors in the logs, just that it did not return anything.

ShellCommandTextReturn(cmd.exe /c powershell Get-WmiObject Win32_ComputerSystemProduct | Select Version)
Answer Summary:
ShellCommandTextReturn(cmd /c powershell "Get-WmiObject Win32_ComputerSystemProduct | Select Version")
0 Comments   [ - ] Hide Comments


Please log in to comment

Answer this question or Comment on this question for clarity



ShellCommandTextReturn(cmd /c "powershell \"Get-WmiObject Win32_ComputerSystemProduct | Select Version\"")

should work. you need to encapsulate it in " because else from Win32 will be interpreted as add. command for cmd

If you have multiple " use \" for escaping them


Answered 09/05/2013 by: Nico_K
Red Belt

  • Thanks Nico. That got me on the right track. I used the rule below and it worked for both the 5.4 and 5.5 agent.

    ShellCommandTextReturn(cmd /c powershell "Get-WmiObject Win32_ComputerSystemProduct | Select Version")
    • great to hear, but in my 5.5GA it only works if I also encapsulate the powershell in ", _THIS_ is strange
      • I thought that would work also? I tested it with a CMD prompt to make sure. I would think that it would not return any results with the command in " ". Since entering it this way in Powershell returns nothing. I'm wondering if it's a Windows thing, and not a Kace thing?

        C:\Windows\system32>cmd /c "powershell get-wmiobject win32_ComputerSystemProduct
        |Select Version"
        'Select' is not recognized as an internal or external command,
        operable program or batch file.

        C:\Windows\system32>cmd /c powershell "get-wmiobject win32_ComputerSystemProduct
        |Select Version"

        ThinkCentre M91p
  • strange, well currently I prefer to end my shift (after 12hr ... again ... ) and don't think about until tomorrow ;)
Please log in to comment