Skip to content

Instantly share code, notes, and snippets.

@yildirima
Created May 17, 2019 08:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yildirima/57cc53a317493876ffa93ba17cad57a9 to your computer and use it in GitHub Desktop.
Save yildirima/57cc53a317493876ffa93ba17cad57a9 to your computer and use it in GitHub Desktop.
#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