Checking for a given file in a directory

Hi, I have a requirement,
I have to write a powershell script with two input params, and this script should return true or false.
Parameter1: Path of a text file which contains a list of file names ( ex: a.txt, test.dll etc).
Parameter2: Search directory. (has folders and subfolders)
I have to search for the fileNames listed in the textfile(input paramater1) in the searchDirectory(parameter2). If any of the fileName exists in any of the (searchDirectory or its folders or subfolders) the script should return 1 else 0.
Please find my below code which is incomplete. Im not sure how to capture GetChildItem result to return 0 or 1.
Please help me with script to achieve the requirement. Thanks in advance.

foreach($FileName in [System.IO.File]::ReadLines($textFilePath))
Get-ChildItem -Path $searchDirectory -Filter $Filename -Recurse


Welcome to the forum. :wave:t4:

If this is an internship assignment or homework question we try to avoid assisting with those as the first port of call should be your tutor or supervisor.

In general - the way you created your foreach loop is very inefficient. You search your searchDirectory for each single input file again and again and again. Instead you should read the directory content once and use this data later on. :wink:

Regardless of that - When you post code, sample data, console output or error messages please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.

Thanks in advance

How to format code in <---- Click :point_up_2:t4: :wink: