scripting - Scheduling Powershell changes ObjectType -


i've written little script checks 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 run active powershell prompt, well. however, when try schedule run daily error on run-time (the block above in try catch mails execution errors):

method invocation failed because [system.management.automation.pscustomobject] doesn't contain method named 'getenumerator'.

how can fix this?

the script may run in different user context when scheduled, potentially different set of read/write permissions on filesystem.

however, in powershell arrays automatically enumerated when used in expressions, don't need call getenumerator() method before passing convertto-html.

you start changing script to:

$resulthtml =  $result | convertto-html 

and see how impacts result.


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -