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