Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Tail File and Notify

$
0
0
Hi All,

I have this code

$computer = gc env:computername
Get-Content -Path 'C:\temp\error.log' -Tail 1 -Wait | where {$_.contains("error")} | ForEach-Object -Process {send-mailmessage -SMTPServer "SMTPSERVER" -to "mailaddress" -from "mailaddress" -subject ($computer+"-Error Detected") -Body $_}

which seems to work however sometimes the value from the Tail goes over multiple line e.g.

Error: The server has produced an error

Check Blah Blah

Is it possibple to return the whole error. When I take out the sendmessage and collect in the PS window then copy the tail line I get the hole lot I guess it has something to do the autosize

Regards

Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>