I've got a weird thing going here in Powershell 1.0 and I don't understand why Powershell is reacting the way it is.
Situation: I've created several zip files on a drive by the letter e:
Now I want to delete them all. But there are more zip files on my e: drive. So I want to delete only the ones in this specific folder and its subfolders.
The command I want to use for this is:
PS E:\> Get-ChildItem -Path E:\Webdev\icons\ -Include *.zip -Recurse -Name -Force | Remove-Item -Force
However, upon execution, I get a bunch of error's, all saying that
Cannot find path E:\test.zip because it does not exist.
Indeed, there is no such file as test.zip directly under e: It does exist under the icons folder which I handed the script.
The solution is for me to change directory to the icons folder and execute the command there.
But this is not logical. I want be able to say in which directory the files should be deleted and then they should be deleted only there. Why Powershell starts looking for the files in the current directory is a mystery to me.
Can anybody explain this to me please?