Regex in Custom Inventory Rule
Hi All,
I am trying to write a custom inventory rule to detect a blank text file on the root c:\ drive. However, the text file will have a different name based on the location of the computer. Here is what I am trying to do FilenamesMatchingRegexExist(C:\,NewComputer.*) . I would ultimately like to have NewComputer(PA|RI)?\.txt as the regex param, but I did the other one for simplicity sake. Unfortunately, neither of these seem to work no matter what I try. Can someone help me out here with what I'm doing wrong?
Thanks,
John
Answers (1)
since you are referencing the root you need 2 \\ otherwise it treats the one as a special chararcter call and tries to include the , in the path name. use FilenamesMatchingRegexExist(C:\\, Newcomputer+.*\.txt)
Took me an hour to debug but, since you are referencing the root you need 2 \\ otherwise it treats the one as a special chararcter call and tries to include the , in the path name.
use FilenamesMatchingRegexExist(C:\\, Newcomputer+.*\.txt)
it will find any file that starts with newcomputer and ends with .txt as extension
https://kbox.freeholdtwp.k12.nj.us/help/doc/Administration/wwhelp/wwhimpl/common/html/wwhelp.htm#href=CustomInventoryID.17.5.html#1019739&single=true
https://kbox.freeholdtwp.k12.nj.us/help/doc/Administration/wwhelp/wwhimpl/common/html/wwhelp.htm#href=CustomInventoryID.17.6.html#1014993&single=true
Comments:
-
wow thank you so much for your time and answer! That is really strange that you have to escape the slash in the filepath. I would have expected it in the regex, but that thought never crossed my mind. Good work! - horstj 11 years ago