Excel.Application not working in PowerShell using SQL Job, but works from command line

Question:

I am using PowerShell to unlock a locked Excel spreadsheet. When I run the script from a job (using myself as the Proxy user), the Excel portion of the script does not run. When I execute the same script directly from the command line, however, it works fine. My code is:

Edit: I added logging. Here are the log results:

Answer:

Ok! Turns out the solution is as follows (in case this shows up in a search result):

  1. Add Directory: C:\Temp
  2. Add Directory: C:\Windows\SysWOW64\config\systemprofile\Desktop

That should fix the problem.

Source:

Excel.Application not working in PowerShell using SQL Job, but works from command line by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply