I am using the PSWriteHTML module to send emails, with nicely formatted tables. For some reason the Email feature is not working when run through PSU. Running the same script from a PS console on the PSU server is running without problems. The error thrown is
Feb 14, 2022 8:40 AM Invoke-Command: C:\Program Files\PowerShell\Modules\PSWriteHTML\0.0.168\PSWriteHTML.psm1:12387
Feb 14, 2022 8:40 AM Line |
Feb 14, 2022 8:40 AM 12387 | [Array] $EmailParameters = Invoke-Command -ScriptBlock $Email
Feb 14, 2022 8:40 AM | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Feb 14, 2022 8:40 AM | Object reference not set to an instance of an object.
It looks like a problem with our custom host in scripts but doesn’t manifest in APIs. You could create an API and then call it from the script with Invoke-RestMethod to work around it.
I’m running into the same problem inside of PowerShell Universal when using the PSWriteHTML Email Function. Is there another way around this? I’ve tried using Send-MailMessage in the PS5.1 Environment but seem to be having the same problem.