/build/static/layout/Breadcrumb_cap_w.png

Systems Management Question


Regex in Custom Inventory Rule

03/22/2013 3920 views

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

Answer Summary:
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)
0 Comments   [ + ] Show comments

Comments


All Answers

4

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

Answered 03/22/2013 by: SMal.tmcc
Red Belt

  • 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!

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

Share

 
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