I got the the following code from stack overflow and it works fine.
$TargetFolder = “Pathofyourfolder”
$Files = Get-ChildItem $TargetFolder -Exclude (gc List.txt) -Recurse
foreach ($File in $Files)
{
write-host “Deleting File $File” -foregroundcolor “Red”;
Remove-Item $File | out-null
}
Now I want to delete the files with file names on the list. I tried some variations of the above such as replacing Exclude with Include but without success. Can anyone help please?