File scan within each user folder?

I'm looking for a way to collect what Outlook signatures are installed on each machine, among some other projects to track user issues, and I'm getting stuck on the file scan in PDQI.

It seems like the scan profile > file scan > path should be able to take a wildcard, but it does not appear to work. Is there a way to get Inventory to just check for files in a subfolder of each user folder?

For this example, I need to check for *.txt files in each of C:\Users\[random user that was logged in]\AppData\Roaming\Microsoft\Signatures\, so I can pull them out into dynamic collections. However, I don't want to pull every .txt in the C:\Users\ folder

Is there any way to do this?



Date Votes
  • Hi Chris,

    At the current time, wildcards are not allowed to be used in the path of the folders, only in the file names themselves.  In the case of what you're trying to accomplish, you'll have to scan the top level folder of C:\Users.

  • Copy this to a text file and save as .cmd file.

    Lines 2-5 get the C:\User or C:\Documents and Settings depending on OS version.

    Line 7 does the hard work... First, the For statement gets a list of directories in %UDir% which will be a list of user names with paths, then the ForFiles statement searches each of those paths (plus the extra path you want searched) for .txt files (the /M part).  The /C part of ForFiles is the command line you want executed on each file found.  You could copy the files to a UNC path the deploy user has write permission to, or anything else!  The FindStr command just quiets most of the extraneous output generated when directories or files are not found in the process.

    These commands should work on Vista up.  Without the findstr command, it should work on Win2k and up, but you may see more (ignorable) error messages or blank lines.  Hope this has given you a starting point.  Good Luck!

    @Echo Off Set UDir=Unknown If Exist "%SystemDrive%\Users" Set UDir=%SystemDrive%\Users If Exist "%SystemDrive%\Documents and Settings" Set UDir=%SystemDrive%\Documents and Settings If %UDir%=="Unknown" Goto End

    For /d %%d in ("%UDir%\*") Do ForFiles /P "%%d\AppData\Roaming\Microsoft\Signatures" /M *.txt /C "Cmd /C Echo @Path" | FindStr ".txt"

    :End Set UDir=

  • Wow, that copy/paste went strange.

    I am attaching a working cmd script to this reply.

  • Jason - I can functionally, but not practically, do what I'm trying to accomplish via C:\Users\ as signatures can be named anything, so (as you alluded to) I would need to pull every single text file in the C:\Users folder and filter out on path in the collections. This is obviously untenable, as the result on a single test machine returned 1800 rows and took ~10 secs to complete.

    Can we consider "a way to scan all the user folders" a feature request? I know it's inbuilt to Windows to use HKU for similar scanning of the registry (and I use it a lot), but it would be fairly handy to have a [Users] base folder for the purposes of file scanning.


    Dwreese - I get that info currently with PDQ Deploy and a similar powershell script, but I was hoping on using the dynamic collection aspect of PDQ Inventory. Thanks for the script, though, that should come in handy if I can't send out a PS.



Please sign in to leave a comment.

Didn't find what you were looking for?

New post