0
votes

I was trying to test a simple powershell script with task scheduler, the status showed running but the powershell console never showed up.

My ps1 script just contains two simple commands:

  • dir
  • pause

Here is my setup:

General

  • Run whether user is logged on or not (check)
  • Run with highest privileges (check)

Actions

  • Action: Start a program
  • Program/Script: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
  • Add arguments (optional): -file E:\iQ_Schedule\Untitled1.ps1

This setup works on other computer (Windows 10) but just won't on this one (Windows Server 2012 R2). I am not sure why.

3

3 Answers

1
votes

Welcome to Session 0 isolation mode.

When you run your task with "Run whether user logged in or not", it runs in so called session 0. You can check this with your task manager.

enter image description here enter image description here

Tasks running is Session 0 has restrictions on showing the user interface

0
votes

This could be due to the user account which is running the script. When the script is running with the SYSTEM account, the script will run in the background.

Try to change the option 'When running the task, use the following user account' to the account you are currently logged on with. Then the PowerShell console should pop up.

0
votes

It sounds like the Windows Server 2012 R2 could have PSversion 2. The Pause function doesn't exist until PSversion 3.

Could you give the value of this command to us?

$PSVersionTable.PSVersion

Run whether user is logged on or not, will still give you the prompt. If the Hidden option is checked, you will not see the prompt.

Hidden is checked.

I have also seen that the user that is trying to run the PowerShell script inside Task Scheduler doesn't have access to the folder strucutre. Make sure the user that is running the Task Scheduler has access to E:\iQ_Schedule\.

Make sure the user that is running the task scheduler has read access to the file structure you are trying to look up.