I want to remove the following files from the source, however in the source there is a sub-directory that contains files with similar names. When I run the following command it is deleting files in the sub-directory with similar file name. Is there a way to just delete the files from the source and not the sub-directory?
Example: test_1_file
, test_2_file
, test_3_file
exists in each directory, TestFolder
and TestFolder/sub
$source = testfolder
remove-item -Path $source -filter test_*_file -recurse -force