I am reaching out for assistance with my current syntax and adjusting my output. I created an analysis that checks “C:\Windows\Temp”, and “E:\Shares\Userprofiles$”, and outputs the total # of files and the total size of all .tmp files found. Currently, my results summary is split up into True/False for files among all machines, but I would like to export this on a per device basis into a .csv file.
My current syntax is the following:
(name of it contains “.tmp” of it) of files of folder "C:\Windows\Temp"
(size of it contains “.tmp” of it) of files of folder "C:\Windows\Temp"
I then created multiple properties per location. I am looking to change it to the following below:
An example output would be;
Device name | Total # of Files | Total size of all files
TestMachine1 | 85 | 900kb
Calculating file sizes using BigFix client relevance can be costly and impact client performance; hence, I would not suggest doing that directly. Instead, you should create a policy action that runs a PowerShell script at the desired time, dumps the values into a text file, and then retrieves the data using relevance.
Looking into files in the folder "C:\Windows\Temp" is doable because it’s limited to one folder and should be configured for infrequent validation over a longer time interval. We can’t apply the same approach to user profiles because it would involve scanning multiple folders of files, which will always be slower and more resource intensive.
You can refer to the following relevance for temporary files:
Since the computer name is already available in BigFix and retrieved property results will correspond to each device, there’s no point in including the hostname in the relevance.
Q: (number of files whose (name of it as string as lowercase contains ".tmp" as lowercase) of folder "C:\Windows\temp" as string & " || " & ((sum of sizes of files whose (name of it as string as lowercase contains ".tmp" as lowercase) of folder "C:\Windows\temp")/ (1024 * 1024)) as string & " MB")
A: 17 || 79 MB
However, if you’re still interested in including the computer name, you can do something like the following:
Q: (computer name as string & " || " & number of files whose (name of it as string as lowercase contains ".tmp" as lowercase) of folder "C:\Windows\temp" as string & " || " & ((sum of sizes of files whose (name of it as string as lowercase contains ".tmp" as lowercase) of folder "C:\Windows\temp")/ (1024 * 1024)) as string & " MB")
A: ABC || 17 || 79 MB
Following up here as I am dealing with a new syntax issue. I am finding a way to check temp files stored on user profiles, and when adjusting your syntax to search for “descendants of folders”, which works normally, it makes files undefined.
Can you assist me in adjusting this to search through the user folders within \Userprofiles$\ for the temp files? I could even adjust more granularly to the actual folder they exist in inside of the folder if you could provide a working example of descendants in this use case.
Q:(computer name as string & " || "& number of files whose (name of it as string as lowercase contains “.tmp” as lowercase) of descendants of folders “E:\Shares\Userprofiles$” as string & " || “& ((sum of sizes of files whose (name of it as string as lowercase contains “.tmp” as lowercase) of folder “C:\Windows\temp”)/ (1024* 1024)) as string & " MB”)
E: The operator “files” is not defined.
Does this work for you? Descendant is already a file object so it was just a case of moving the whose clause before the descendants and dropping the files part.
Q: (computer name as string & " || "& number of descendants whose (name of it as string as lowercase contains ".tmp" as lowercase) of folders "E:\Shares\Userprofiles$" as string & " || "& ((sum of sizes of files whose (name of it as string as lowercase contains ".tmp" as lowercase) of folder "C:\Windows\temp")/ (1024* 1024)) as string & " MB")
Just to illustrate using the C:\Windows\temp folder
Q: number of descendants whose (name of it as string as lowercase contains ".tmp" as lowercase) of folders "C:\Windows\temp"
A: 14
T: 20.510 ms
I: singular integer
Just a side thought, using whose (name of it as string as lowercase ends with ".tmp" as lowercase) might avoid cases where files such as “filename.tmp.bak” or “filename.tmp.old” may exist, depending on your requirements and environement.