04/17/2019 343 views

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:


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


All Answers


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)
Answered 04/17/2019 by: flip1001
Fifth Degree Brown Belt

  • Or if you prefer powershell something like this

    if ((gci C:\Users\SpecificUser\Downloads).count -ne 0) {"Folder not empty"}
  • 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.
    • 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.
      • 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.