I have an ObjectEvent that sees a new file getting created and then tries to move the file.
It works... except when it goes to move the file, the file is still open, so the Move-Item fails.
So I suppose there are two possible paths... I am open to either (or both!)
First, how would my ObjectEvent fire only after the file is closed? Current objectevent:
Register-ObjectEvent $Watcher -EventName Created -SourceIdentifier FileCreated -Action
Second, is it possible for MoveItem to sit and keep trying for 5 seconds or so before failing? Current Move-Item call:
Move-Item $path -Destination $destination -Force -Verbose