Forum Discussion

Deleted's avatar
Deleted
Oct 29, 2020

Running power shell script from task scheduler

(using windows server 2016)

 

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 https://blog.danskingdom.com/keep-powershell-console-window-open-after-script-finishes-running/, I tried:

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

 

The script runs fine apart from the console window not remaining open (I can't even see it momentarily appear) I also tried adding to 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

No Replies