0

I have a script which works when it is manually executed the script works under these conditions:

1) I start start.ps1 which then elevates with admin user then executes main.ps1 script

2) the start.ps1 is being run without any rights and I am elevating it by using

 Start-Process -FilePath Powershell -LoadUserProfile -Credential $credential -ArgumentList '-File', $script 

Everything works fine, please note that new powershell window appear and main.ps1 is being executed there.

now, when I create a scheduled task, then run it - I can see in the task manager that main.ps1 is being executed but noting is happening apart from task being stuck in scheduler. I cant use admin user in task scheduler it has to be executed as non privileged user.

Do you have any ideas how to fix this issue?

I have tried running it under local user, with/or without execution policy set to bypass/unrestricted etc nothing helped.

Thanks in advance

user5711825
  • 85
  • 1
  • 1
  • 11
  • can you run it as the "System" user via Task Scheduler? – Bajan Feb 15 '17 at 17:07
  • when running as System nothing is happening, the task starts, it runs then completes with "the operation completed successfully (0x0)", it takes around 1 sec to complete it. Normally this scheduled task should run for around 10 min. – user5711825 Feb 15 '17 at 17:34

0 Answers0