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