Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tail File and Notify

Status
Not open for further replies.

Leighton21

Technical User
Dec 17, 2001
83
AU
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 "someaddress@someaddress.com" -from "someaddress@someaddress.com" -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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top