0
I have the following AppPoolActivation.ps1
file, to call a URL :-
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
$request = [System.Net.WebRequest]::Create("https://IPADDRESS***/")
$response = $request.GetResponse()
$response.Close()
and I wrote the following app.bat
file to call the above AppPoolActivation.ps1
file:-
"%SYSTEMROOT%\system32\windowspowershell\v1.0\powershell.exe" -Command Start-Process "$PSHOME\powershell.exe" -Verb RunAs -ArgumentList "'-NoExit %~dp0\AppPoolActivation.ps1'
Then inside my windows server 2012 windows tasks scheduler , I define a Daily task which run each 15 minutes for a duration of 1 day, so mainly it will always run each 15 minutes, and I define this task to call the .bat file, as follow:-
now when I first define the task it worked well for around 5 hours, but I have noted that after 10-12 hours the server will be very slow till it stop responding, now I check the task manager on the server and I find that there will be many instances of windows power shell & Console windows host running, as follow:-
so can anyone advice how I can overcome this problem ? I mean why there will be many instances of windows power shell & Console windows host running ? and is there a way to prevent this from happening and prevent my server to became very slow due to the task schedule ? baring in mind that I have never face any problem on this server for around many years ago ,, the problem started when I create this schedule task...
I tried your approach at the beginning to call the .ps1 directly from the task, but it never succeed I think the problem is related to a policy that we can not run PowerShell scripts ,,,now what I did I modify the current .bat file and I remove the "-NoExit" from it, and now I can not see repeated processes inside my task manager,, seems -NoExit will not end the process once the powershell script ends, I thought -NoExit will prevent the process from being ended during the execution, but seems it mean to never end the process even after it is being completed.. – John John – 2016-02-15T15:42:33.953
1
@JohnJohn You can bypass execution policy with from Task Manager too. See updated answer.
– beatcracker – 2016-02-15T17:27:04.947"seems -NoExit will not end the process once the powershell script ends"
- yep, see PowerShell.exe Command-Line Help.