I wrote a powershell script to print out pdf's and send an email to myself. When i run it in powershell from my account it works perfecly. When I convert the script into an exe (using POWERGUI) it still runs fine.
The issue that I have is that when I call that exe from an ssis package ( it runs as an admin account) then the print doesn't work but the email still sends.
My guess is that this occurs because the Print function popsup adobe acrobat and that most likely causes it to not print when ran in the background as another account. Here is my code:
Try
{
Start-Process -FilePath $UNCpath –Verb Print -WindowStyle Hidden -PassThru | %{sleep 10;$_} | kill
Send-MailMessage -To "myaccount@work.com" -From "myaccount@work.com" -Subject 'printing from script' -SmtpServer "mail.work.com" -Body $path
return 1
}
Catch [system.exception]
{
write-host "ERROR: caught a system exception printing"
}
return 0