automate powershell script in background ?

Hi all
I'm sort of migrating my performance-monitor script from linux to windows, and i recently discovered PowerShell. Kinda start loving it!

cron-job in linux has really low performance footprint. In windows, i tried to call my PS script in scheduled Task via command "powershell.exe scriptname.ps1"

The problem i discovered was that CPU usage shoots up to 100% everything powershell.exe came into the picture.

Similar thing happened when I manually execute " powershell.exe sriptname.ps1 " from CMD.
If I simply call scriptname.ps1 from the PS console, then there's no effect on computer-performance.

So, my question is that there is any way to get around callling powershell.exe while doing automation PS.
many thanks!

Who is Participating?
Joe KlimisCommented:
try creating a powershell script call test.ps1 containing the following line  

sleep -s 60   #  sleep for 60 seconds

from the command prompt type

powershell.exe -command "test.ps1"

Then monitor this , if this is ok, check you are not trying to write output  to the host
Bryan ButlerCommented:
Does it stay at 100%?  I would think it goes to 100 while starting the shell, but then should go back down.  When you run it from the prompt, the shell is running already.  
valleytechAuthor Commented:
It is just a spike. I guess that's typical for application when being loaded, yes?
Bryan ButlerCommented:
It is typical as powershell loads the .net framework when it starts.
valleytechAuthor Commented:
I found the solution!
many thanks!!!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.