I am trying to run a TaskScheduler task on a Virtual Machine. The issue is, when I set the Security Options to "Run whether user is logged on or not," with the highest priviledges (Selected user account is an Domain Admin), the task fails. My PowerShell script writes a temporary XLSX file into a folder in the C: and promptly removes it after it is uploaded to a FTP site. I am getting permission issues where the remote computer cannot save files into the C:.
I spent hours Googling this issue and so far I've found no solid answers.
My TaskScheduler task is located within an admin account in the Virtual Machine. It does not fail when the security option is set to "Run only when user is logged on."
Does anyone have any ideas?
I attempted to remote in by enabling PSRemoting and using a separate machine with Admin credentials. Even then I am unable to create any excel files using the workbook.saveas() function.
I verbosed the messages I am receiving from my script.
Debug Log: 02/06/2015 14:31:19
C:\Users\SQLADMIN\Desktop
Exception calling "InvokeScript" with "1" argument(s): "Unable to save to
C:\Users\SQLADMIN\Desktop\FTP_MYS_Upload\ExhibitorCompaniesDetails.xlsx.
Please ensure you have write access."
At C:\Users\SQLADMIN\Desktop\FTP_MYS_Upload\Export-XLSX with Excel.ps1:168
char:13
+ $ExecutionContext.InvokeCommand.InvokeScript($Script)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : RuntimeException
Exception calling "InvokeScript" with "1" argument(s): "Unable to save to
C:\Users\SQLADMIN\Desktop\FTP_MYS_Upload\ExhibitorCompaniesExpoHistory.xlsx.
Please ensure you have write access."
At C:\Users\SQLADMIN\Desktop\FTP_MYS_Upload\Export-XLSX with Excel.ps1:168
char:13
+ $ExecutionContext.InvokeCommand.InvokeScript($Script)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : RuntimeException
The "Unable to save to DIR. Please ensure you have write access" is a try catch for the .saveas() method in my create XLSX script.
I can out-file remotely, essentially creating a txt document but I cannot use the .saveas() method. Any ideas? Does it have to do with Excel/Powershell?
Looks like its a dotNet issue. dotNet does not play nicely when it calls Excel remotely. I'll investigate further.