Returns the lines of the given text file(s) matching the supplied regular expression pattern.


FilePath (string): The full path of the file. Similar to the GetFile method, the path can include environment variables represented by the local shell format (e.g. %env% on Windows), and wildcards such as '*' for multiple characters and '?' for a single character.

RegExp (string; optional, default: empty string): A regular expression pattern in ECMA-262 ECMAScript format for the lines to match. If not supplied, every line will be returned.

Return values

A maximum of 50,000 lines is returned.

For each line of each file matching the pattern found:

    • FileName (string): The full path, with any wildcards and environment variables expanded.
    • LineNumber (int): The line number, starting at 1.
    • Content (string): The content of the line that contains a match for the regular expression.

Search the ConfigMgr WUAHandler log for any errors.

FileSystem.GetFileByLine(FileName:"c:\\Windows\\CCM\\Logs\\WUAHandler.log", RegExp:"[eE]rror");

By default, the search is case sensitive. Here we are using RexExp to search for both Error and error.

  • Windows
  • Linux
  • MacOS
  • Solaris Intel
  • Solaris Sparc

Do not use on a binary file - the returned Content will probably be corrupted.

A good site to help understand basic regular expressions is

Uses ECMA262 format for regular expressions: