I've got a batch file which used to execute a Powershell script.
Code: Select all
powershell -command "& 'C:\JobsScripts\ScriptFiles\AgentJobStatusEmail.ps1' "
The PoSh script executes successfully from within the PowerGUI script editor and the batch file executes the PoSh script successfully from a command prompt. (Both executions use my AdminAccount)
However, when executed via the Task Scheduler, everything seems to be working, except for the creation (and hence the attachment) of the Excel file, as there is no .xlsx file in the saved to folder and an attachment-less email is received. The task itself, is set to use my AdminAccount with "run with highest priviledges".
I have a NormalUser AD account that I use to log into my work station. Both my NormalUser and my AdminAccount are members of an AD group which is a member of the Administrators group on my work station. For opening the PowerGUI script editor or the command prompt, I use RunAs in a shortcut and use my AD AdminAccount, as it is this account which is a SQL Server sysadmin and member of the Administrators group on all the servers running an instance of SQL Server.
Code: Select all
%windir%\system32\runas.exe /user:domain\AdminAccount "C:\WINDOWS\system32\cmd.exe"
%windir%\system32\runas.exe /user:domain\AdminAccount "C:\Program Files (x86)\PowerGUI\ScriptEditor.exe"
So....what are the permission(s)/method(s) needed or a work around so I can accomplish this task?
Thank you.