Is it possible to define an array of filenames (all files in different folders) and then in a loop delete them all, or do something else?
Actually I need to create a few symbolic links using mklink to one file, putting those links in a different folders, replacing the old links if there was any.
Deleting an array of filenames is simple:
Or via a variable:
And then based on all files in different folders:
Remove the
-WhatIfto do the actual removal.If you want to delete a file with a specific name you could use the
-Filterparameter onGet-ChildItem. This would be the best performing approach:If the name requires more sophisticated matching then you can use a regex in a Where scriptblock e.g.: