This is what I have but its not correct.
(Get-Content C:\Users\U0146121\Desktop\Output.txt) |
ForEach-Object {
Compare-Object -referenceobject $_ -DifferenceObject $(get-content C:\Users\U0146121\Desktop\New folder\filenames.txt) -IncludeEqual
}
I want to compare the current line and see if it is in the filenames.txt If it is then write the name to a new txt file.