Schedule a PowerShell script execution

Creation of a scheduled task (Windows 2008 only)

Import-Module TaskScheduler
$Script = "ToBeDefined"

$task = New-Task
$task.Settings.Hidden = $true

Add-TaskAction -Task $task -Path powershell.exe -Arguments "-File $Script"
# Daily Execution, 8AM
Add-TaskTrigger -Task $task -Daily -At "08:00"

Register-ScheduledTask -Name "PowerShell Task - $Script" -Task $task

Leave a Reply

Scroll to Top