PowerShell Script to monitor folder and trigger batch file and send mail

I need your help to create a PowerShell script to monitor the folder (live), and if 10 JPG Files created today, trigger another patch file and send mail.

  • I tried to combine multiple commands as below but still its not working as it should be


    $r = Get-Childitem $folder * -Recurse |
    Where-Object {$_.CreationTime -gt (Get-Date).Date } |

    if ($r.Count -ge 10) {
    Start-Process c:\users\mmahgoub\Desktop\1.bat
    } else {
    write-host "Less than 10 files created under $folder"