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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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?
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bryan ButlerCommented:
It is typical as powershell loads the .net framework when it starts.
valleytechAuthor Commented:
I found the solution!
many thanks!!!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.