0

What is the difference between running this command:

Invoke-Command -ComputerName $computername -Credential $username -ScriptBlock { PowerShell $scriptPath $param1 $param2 } 

and running a scheduled task that runs the same script with the same parameters, same user (Option "Run whether user is logged on or not")?

My script opens Excel which loads some data, calculates with matlab and then saves. Everything works fine when the script runs via task scheduler. However, when I do this directly (without task scheduler), Excel just hangs. As far as I was able to debug, it just hangs (runs in the background doing nothing) when the Activeworkbook.Refreshall command is supposed to execute.

What am I missing?

Thanks in advance! :)

  • Activeworkbook.Refreshall is a vba command, not powershell – Cole9350 May 19 '14 at 13:42
  • Of course. But my script launches Excel (in both cases the same Excel file) which runs a VBA command ActiveWorkbook.Refreshall. However, if Excel is ran remotely via PowerShell, the command doesn't seem to work, but if the Excel is ran via task scheduler, the RefreshAll command works... – user3652540 May 19 '14 at 14:24
  • http://stackoverflow.com/questions/16347214/pass-arguments-to-a-scriptblock-in-powershell – Cole9350 May 19 '14 at 17:37

0 Answers0