I want a powershell script to be run once per minute in the background. No window may appear. How do I do it?
+2
A:
Use the Windows Task Scheduler and run your script like this:
powershell -File myScript.ps1 -WindowStyle Hidden
Furthermore create the script that it runs under a specific user account and not only when that user is logged on. Otherwise you'll see a console window.
Joey
2010-01-15 12:47:14
I now, but how do I run the powershell in the background?
magol
2010-01-15 12:48:04
@magol - How much more "background" do you need to get? The Windows task scheduler is how you would run a "background" task, and in this case, the task would be to start PowerShell and run the specified script.
Steven Murawski
2010-01-15 15:52:36
Well, to be fair, the initial answer wouldn't have resulted in a background process if the current user is an administrator and doesn't change the default settings for the task. However, explicitly letting the task run regardless of the logged-on user fixes that. Hm. My test script ran 181 times so far. I should turn that task off again :-)
Joey
2010-01-15 15:57:45
magol
2010-01-19 10:21:21