Last active
November 29, 2016 09:39
-
-
Save sushanthmangalore/ae1465adf0997a0b68b7499c80c93e95 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$folder = 'D:\Web' # <-- Provided the fully qualified directory path | |
$filter = '*.txt' # <-- Set this according to your requirements. Matches the file patterns within the directory | |
$fsw = New-Object IO.FileSystemWatcher $folder, $filter -Property @{ | |
IncludeSubdirectories = $true # <-- Set this according to your requirements | |
} | |
$onCreated = Register-ObjectEvent $fsw Created -SourceIdentifier FileCreated -Action { | |
$path = $Event.SourceEventArgs.FullPath | |
$name = $Event.SourceEventArgs.Name | |
$changeType = $Event.SourceEventArgs.ChangeType | |
$timeStamp = $Event.TimeGenerated | |
Write-Host "The file '$name' was $changeType at $timeStamp" | |
# <-- Plugin code to send the e-mail notification/move the file here. | |
Send-MailMessage -SmtpServer "localhost" -To "sushanth_mangalore@infosys.com" -From "sushanth_mangalore@infosys.com" -Subject "Hello" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
E-mail sending can be tested with a fake SMTP server like - https://nilhcem.github.io/FakeSMTP/index.html#