Running PowerShell Scripts from Windows Task Scheduler
Sometimes, we write scripts that we want to schedule. For example, I recently put together a small script that checks an environment for Snapshots that are older than 7 days and then emails the sys admins a report if it finds any. Alan Renouf put together a quick guide on how to run PowerShell scripts with Windows Task Scheduler back in 2009, but I ran into a hiccup while trying to use that procedure the other day. Alan suggests two possible methods for accomplishing this task. One involves editing your scripts to add the required PS Snapins and the other involves launching the PowerShell session from a pre-configured Console File. I decided that I’d had enough of messing around with Add-PSSnapin, so I decided to experiment with the PowerShell Console option. The example syntax that he provides is basically: Powershell.exe –PSConsoleFile myConsole.psc1 & myScript.ps1 Which didn’t exactly work for me. When I executed this at a command line, it started PowerShell and