I have a list of filenames in a text file like this:
f1.txt f2 f3.jpg
How do I delete everything else from a folder except these files in P
If the files exist in the current folder then you can do this:
Get-ChildItem -exclude (gc exclusions.txt) | Remove-Item -whatif
This approach assumes each file is on a separate line. If the files exist in subfolders then I would go with Oisin's approach.