Created
May 17, 2019 08:09
-
-
Save yildirima/57cc53a317493876ffa93ba17cad57a9 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
#Abdurrahim YILDIRIM# | |
#Define file that you need to monitor#### | |
$targetFile = "C:\HPOM\ProgramData\HP\HP BTO Software\shared\tmp\queues\MsgQueue" | |
$path_file = "C:\HPOOconfig\SystemControl\quee_size_control" | |
$fileSize = ((Get-Item $targetFile).length/1KB) | |
$friendlySize = ([math]::Round($fileSize, 2)) | |
$sto = "yourmail@casesup.com" | |
echo $fileSize | |
if ($fileSize -gt 100) | |
{ | |
if (Test-Path $path_file) | |
{ | |
echo $fileSize >> $path_file | |
} | |
else | |
{ | |
echo $fileSize >> $path_file | |
Send-MailMessage -To $sto -From localmachine@test.com -SMTPServer smtpx.casesup.com -Subject "FileMonitor - Alert " -Body "$targetFile file size $friendlySize KB." | |
} | |
} | |
else | |
{ | |
if (Test-Path $path_file) | |
{ | |
Send-MailMessage -To $sto -From localmachine@test.com -SMTPServer smtpx.casesup.com -Subject "FileMonitor - Alert " -Body "$targetFile file size $friendlySize KB." | |
del $path_file | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment