I want a powershell script to be run once per minute in the background. No window may appear. How do I do it?
On the [General] tab in the Task Scheduler properties for the task, selecting the "Run whether user is logged on or not" radio button prevents the window from appearing on my Windows 7 machine.
To create a background powershell task to run a script that repeats every minute with no visible window at all, run powershell as administrator and then use the Register-ScheduledJob
cmdlet to run your script. Here's an example of how to make that happen:
Register-ScheduledJob -Name 'SomeJobName' -FilePath 'path\to\your\ps1' -Trigger (New-JobTrigger -Once -At "9/28/2018 0am" -RepetitionInterval (New-TimeSpan -Minutes 1) -RepetitionDuration ([TimeSpan]::MaxValue))
If you want to manually force this job to run (perhaps for troubleshooting purposes) you can use the Get-ScheduledJob
cmdlet like this:
(Get-ScheduledJob -Name 'SomeJobName').StartJob()