Running power shell script from task scheduler

Deleted
Not applicable

(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 keep-powershell-console-window, 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

0 Replies
www.000webhost.com