powershell get-childitem include option

I have two line of code that does get-childitem to search for files. I am using get-content to retrieve the data from a text file.

The command appears to be correct if I use write-host to display the command. However the data is clearly not in the properly format because the search returns nothing.

$file=(gc .\filelist.txt) -join ",";
gci -Pa $path -In $file -Re

Open in new window

LVL 21
Who is Participating?
SubsunConnect With a Mentor Commented:
$file= gc .\filelist.txt
gci -Pa $path -In $file -Re

Open in new window

filelist.txt should be like..

Open in new window

MazdajaiAuthor Commented:
Oh boy. This is embarrassing. I thought the include option has to separate by comma.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.