I am trying to use Get-ChildItem to produce a list of files, which I then want to delete, and then run the script again every five minutes via Task Scheduler, i.e. a fairly basic folder-watch task.
However it seems that the list of files is getting cached, so that newly created files are not 'seen' by the script...
Get-ChildItem –Path "\\server\share$\my\path" | where {($_ -like "_minidump_default_pid*.dmp")} | Remove-Item -Force | Out-File D:\MiniDump_Delete_Output.txt –Append
I then write a single char to the output file, so I can see that the task runs as expected.