Windows 10 Keep Console Open after running power shell script through task scheduler

  • Thread starter Thread starter HareshGP
  • Start date Start date
H

HareshGP

I am running a powershell script using task scheduler:

Program/Script: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

Add arguments (optional): C:\Users\Administrator\Desktop\JO.ps1



This works fine. However I want the powershell console to remain open. After looking at this article keep-powershell-console-window, I tried:


1.) Adding an argument within task scheduler

Add arguments (optional): -NoExit "C:\Users\Administrator\Desktop\JO.ps1"

The script runs fine but the console window does not remaining open (I can't even see it momentarily appear).


2.) Changing the script file itself

I added the following line to the end of my script: Read-Host -Prompt "Press Enter to exit"

When the script is run manually the console window remains open, but if the script is run through the task scheduler the console window does not remain open.



Please help.

Haresh


Continue reading...
 

Similar threads

D
Replies
0
Views
11
Danial Hussain
D
S
Replies
0
Views
10
Sterling R
S
A
Replies
0
Views
15
Alexandra Burlacu
A
Back
Top