I've written a little script that checks for differences between 2 text files.
$new = get-content $outPutFile
$old = get-content $outPutFileYesterday
$result = $null
$result = Compare-Object $old $new
$resultHTML = $result.GetEnumerator() | ConvertTo-Html
Send-MailMessage -SmtpServer 10.14.23.4 -From me@mail.com -To $toAddress -Subject "DiffTest" -Body "$resultHTML" -BodyAsHtml
When I run it from an active PowerShell prompt, all is well. However, when I try to schedule it to run daily I get this error on the run-time (the block above is in a try catch that mails any execution errors):
Method invocation failed because [System.Management.Automation.PSCustomObject] doesn't contain a method named 'GetEnumerator'.
How can I fix this?