/build/static/layout/Breadcrumb_cap_w.png

5.5 Agent Custom Inventory Rule -Powershell

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)

0 Comments   [ + ] Show comments

Answers (1)

Answer Summary:
ShellCommandTextReturn(cmd /c powershell "Get-WmiObject Win32_ComputerSystemProduct | Select Version")
Posted by: Nico_K 10 years ago
Red Belt
2

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

 


Comments:
  • 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") - dugullett 10 years ago
    • great to hear, but in my 5.5GA it only works if I also encapsulate the powershell in ", _THIS_ is strange - Nico_K 10 years ago
      • 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"

        Version
        -------
        ThinkCentre M91p - dugullett 10 years ago
  • strange, well currently I prefer to end my shift (after 12hr ... again ... ) and don't think about until tomorrow ;) - Nico_K 10 years ago

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ