I am having withthe following problem. I gothave a powershell script to send me emails with log files attached. The only problem is that i needI need only the log files that are not empty. So i have mytried to use this script like that:
If ((Get-content "Log.txt") -gt 0 ) { $smtp.Send($msg) echo "email sent" } else { echo "File is blank" }
If ((Get-content "Log.txt") -gt 0 ) { $smtp.Send($msg) echo "email sent" } else { echo "File is blank" } It seems that -gt 0-gt 0 is not working for me. No matter what iI have tried powershell still sends me emails even withthe empty logs. So can you please show me where iI am wrong in that little piece of code.? I have tried that onethis as well:
If ((Get-Content $file) -eq $Null) { "File is blank" } else { $smtp.Send($msg) echo "email sent" } If ((Get-Content $file) -eq $Null) { "FileBut it is blank" } else { $smtp.Send($msg) echo "email sent" } Bu still not working.
Thank you in advance.