Binoj P N, June 21, 2017 - 6:53 am UTC
Hi,
Thanks for the suggestion, we are using Windows.
Still I will try to convert this powershell according to the Windows script.
Regards
Binoj
June 22, 2017 - 4:52 am UTC
if you get a powershell script running nicely, be sure to post it or blog about it so others will benefit as well
IF condition for folder size.
Binoj P N, June 27, 2017 - 7:47 am UTC
Hi,
I am managed to do something, but not table to make the exact IF Condition.
$smtpServer = "IP Address"
$smtpFrom = "name@com"
$smtpTo = "name@com"
$messageSubject = "Listener size"
$messageBody = "The listener size is:"
$file = 'path\'
$objFSO = New-Object -com Scripting.FileSystemObject
"{0:N2}" -f (($objFSO.GetFolder($file).Size) / 1MB)
if ($objFSO = 277.75)
{
$smtp = New-Object Net.Mail.SmtpClient($smtpServer)
$smtp.Send($smtpFrom,$smtpTo,$messagesubject,$objFSO)
}
I want to send alert mail, if the entire FOLDER's size cross 1 GB.
But when I tried, it is not accepting either greater than nor less than symbols.
It accepts only the equal to value.
Need your advice.
Regards
Binoj
June 28, 2017 - 12:48 am UTC
Let me reiterate
"I'm not a powershell expert"
:-)
Found the solution
Binoj P N, June 28, 2017 - 6:53 am UTC
Hi,
Finally I have found the solution.
Here it is.
$smtpServer = "my_mail_server"
$smtpFrom = "alert@my_company.com"
$smtpTo = "dba@my_company.com"
$messageSubject = "Listener size"
$messageBody = "The listener is more than 1000M"
$file = 'c:\....\listener.log'
$mail="The folder's total size is:- "
$objFSO = New-Object -com Scripting.FileSystemObject
"{0:N2}" -f (($objFSO.GetFolder($file).Size) / 1MB)
$value= (($objFSO.GetFolder($file).Size) / 1MB)
if ($value -gt 278)
{
$smtp = New-Object Net.Mail.SmtpClient($smtpServer)
$smtp.Send($smtpFrom,$smtpTo,$messagesubject,$mail+$value)
}
Regards
Binoj
June 29, 2017 - 1:56 am UTC
Thanks for taking the time to come back here and post this.
It will be helpful for other people on Windows.