/build/static/layout/Breadcrumb_cap_w.png

Custom Inventory Rule with Powershell not finding results

Hello!

I'm trying to create a CIR which will eventually be used with a report to identify all local users on a workstation, except a few select expected users. However, when the rule is created, it is turning up no results. I haven't really worked a lot with CIRs so my code may be off so I was hoping to get some great insight about the process. Any help would be greatly appreciated.


ShellCommandTextReturn(C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Bypass "invoke-command -ScriptBlock {Get-LocalUser | Where-object {($_.Name -notlike "Guest") -AND ($_.Name -notlike "DefaultAccount") -AND ($_.name -notlike "Account3")} | select Name} -ErrorAction SilentlyContinue" 2> nul)

0 Comments   [ + ] Show comments

Answers (2)

Posted by: vigasi 1 year ago
Senior White Belt
1

Hello- Here is what I currently use.  I try to keep it simple.  If it works, then I tweak it.

ShellCommandTextReturn(c:\windows\sysnative\WindowsPowerShell\v1.0\powershell.exe Get-LocalUser)


Have fun!

Comments:
  • Thanks! That did solve the issue of it not returning results at all. I was missing the "Sysnative" alias. Now, the question is, how do I get it to exclude certain results. When I add in the "Where-object" cmdlt, it no longer runs. - BebopFloyd 1 year ago
Posted by: jlfrank 1 year ago
Yellow Belt
0

Try adding "| Select-Object" to the end of the cmdlet.

 
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