I call a Powershell script from a c# program, getting back an collection of PSObjects as a result of pipeline.Invoke(). As a part of the PS script, an email is sent using Net.Mail.SmtpClient. However, sending an email takes some time, so I moved the email sending code into a script block that is executed using Start-Jon -ScriptBlock... And here the problem started: email is not sent. When I execute a script from a command line, it sends an email.
What can be the reason?
pipelinereturn no errors, script works (in a sense that it returns processed data back to the c# program. Just email is not sent.