Skip to main content
Fixed spelling and grammar. Put code in code blocks.
Source Link

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.

I am having with following problem. I got 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 my script like that:

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 sends me emails even with empty logs. So can you please show me where i am wrong in that little piece of code. I have tried that one as well:

If ((Get-Content $file) -eq $Null) { "File is blank" } else { $smtp.Send($msg) echo "email sent" } Bu still not working.

Thank you in advance.

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.

Source Link

Powershell send mail

I am having with following problem. I got 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 my script like that:

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 sends me emails even with empty logs. So can you please show me where i am wrong in that little piece of code. I have tried that one as well:

If ((Get-Content $file) -eq $Null) { "File is blank" } else { $smtp.Send($msg) echo "email sent" } Bu still not working.

Thank you in advance.