You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
1.3 KiB

# <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD>У<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD>б<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȴ<EFBFBD><EFBFBD>ڡ<EFBFBD>
$folder = 'D:\images\'
# <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD>μ<EFBFBD><EFBFBD>صļ<EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ1000<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><EFBFBD>
$timeout = 1000
# <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>ϵͳ<EFBFBD><EFBFBD><EFBFBD>Ӷ<EFBFBD><EFBFBD><EFBFBD>
$FileSystemWatcher = New-Object System.IO.FileSystemWatcher $folder
# <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD>µ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>
$FileSystemWatcher.IncludeSubdirectories = $true;
# <EFBFBD><EFBFBD><EFBFBD>˼<EFBFBD><EFBFBD>ص<EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
$FileSystemWatcher.Filter = "*.as*";
Write-Host <EFBFBD><EFBFBD><EFBFBD><EFBFBD> CTRL+C <EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD> $folder <EFBFBD>ļ<EFBFBD><EFBFBD>ء<EFBFBD>
while ($true) {
# <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>б仯
$result = $FileSystemWatcher.WaitForChanged('all', $timeout)
if ($result.TimedOut -eq $false)
{
# <EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD>е<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݱ仯ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
Write-Warning ('File {0} : {1}' -f $result.ChangeType, $result.name)
$title = ('File {0} : {1}' -f $result.ChangeType, $result.name)
$body = ('File {0} : {1}{2}' -f $result.ChangeType, $folder,$result.name)
# (Get-Credential).password | ConvertFrom-SecureString > mpass.txt <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>smt<EFBFBD><EFBFBD>֤<EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
$pw = Get-Content .\mpass.txt | ConvertTo-SecureString
$cred = New-Object System.Management.Automation.PSCredential "noreplay@test.com", $pw
Send-MailMessage -To yaokuaile@kaihejia.com -from "<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <noreplay@test.com>" -Subject "$title" -Body "$body" -encoding ([System.Text.Encoding]::UTF8) -priority High -smtpServer smtp.test.com -Credential $cred;
}
}
Write-Host '<EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD>ȡ<EFBFBD><EFBFBD>.'