Execute powershell script as a scheduled task

I have a little cleanup function that runs on a website that I can trigger by hitting a URL. I wanted to run that as a task, so I googled how to create the powershell script and how to setup that script to run as a task. Here are the findings:

The powershell script

$webClient = new-object System.Net.WebClient
$webClient.Headers.Add("user-agent", "PowerShell Script")

From Otto Helweg

Setting up the task

In the Program/script, put:

In the Add arguments (optional):
-noninteractive -nologo c:\pathtofile\powershellscript.ps1

From TechNet

Powershell Cookbook

I have been working on a LOT of automation scripting, and for whatever reason whenever I did this int he past I always used batch files – I guess I was just used to it? Whatever…

I got smart (finally) and started using Powershell and I have been able to do some pretty cool automation (post with scripts incoming). Powershell has a quirky syntax, and I have been doing lots of googling. I just ran across the Powershell Cookbook. Pretty good stuff…