Powershell- Monitor and Run

How to monitor a folder for a new sub-folder created and then monitor the new subfolder for a file for a specific timeframe? When the file is detected within the timeframe, run another file in a different drive and exit. If the file is not detected within the timeframe, then exit?

$watcher = New-Object System.IO.FileSystemWatcher
$watcher.Path = ‘Z:\abc’
$watcher.Filter =‘.
IncludeSubdirectories = $true
$watcher.Filter = ‘xyz.txt’
$watcher.EnableRaisingEvents = $true

$onCreated = Register-ObjectEvent $fsw Created -SourceIdentifier FileCreated -action {
$path =$event.SourceEventArgs.FullPath
$changeType + $Event.SourceEventsArgs. ChangeType

…STUCK HERE

Sandy,
Weclome to the forum. :wave:t4:

giphy

The following might push you to the right direction: