/build/static/layout/Breadcrumb_cap_w.png

K1000 (8.1) need a custom inventory rule CIR to find computers with a certain folder non-empty

We have a subset of machines that should never have files in the Downloads folder -- and if they do, something else is amiss. I'm looking to create a CIR (or another path, if you know of a better one!) to locate computers that have C:\Users\[SpecificUser]\Downloads NOT empty. 


I've tried a CIR of FileExists(path), in this way:

FileExists(C:\Users\[SpecificUser]\Downloads\*.*


However this seems to return basically everything that inventories ( the user [SpecificUser] is actually built into most of the PCs on our system, but only rarely used).


Do you have any ideas? Maybe a script would handle this better?



0 Comments   [ + ] Show comments

Answers (1)

Posted by: flip1001 5 years ago
Black Belt
0

I tried this successfully in a command prompt but I didn't try it at as a CIR.


DirectoryExists(C:\Users\SpecificUser\Downloads) AND ShellCommandTextReturn(cmd /c dir /A C:\Users\SpecificUser\Downloads | find " 0 File(s) " > nul || echo Folder not empty)

Comments:
  • Or if you prefer powershell something like this

    if ((gci C:\Users\SpecificUser\Downloads).count -ne 0) {"Folder not empty"} - flip1001 5 years ago
  • I agree the above works in cmd but hasn't yet worked out as a CIR. It weirdly returned just like 6 clients, half of which had stuff in Downloads and the other half didn't. Still working on it. - agibbons 5 years ago
    • The dir /a command shows all files including hidden. Maybe the other half has hidden files? You can remove the /a parameter to only show regular files. - flip1001 5 years ago
      • Thanks! Good thought. I'll give it a shot -- I let the CIR roll for a day, which should have presented me with 100s of clients with stuff in downloads folders. It is strange that it did not. - agibbons 5 years ago
 
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