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.

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

    $folder="G:\icnos"

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

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

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

    $folder="G:\icnos"

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

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

Children
No Data