I am trying to find a way to deal with such task:
there are several directories which are named differently. They contain 2 files hi.exe and newScript.bat I need to write script that looks in the current directory and its descendants for folders containing these two files, deletes those, then deletes the containing directory.
I found a way to delete those files and how to delete an empty directory. Is there a way to link directory name before deleting those files? Or any other way?
I found a way to delete files, but I need to save their paths somehow and then delete a folder :
Remove-Item -path H:* -include hi.exe , newScript.bat -recurse -whatif
Also I can delete empty folders but it's not a solution that I am looking for.
Upd: Why with -and it is not working? But it works fine with -or? powershell execution