Schedule a Task via Powershell on remote systems

Scenario:  You want to schedule a task remotely via Powershell on remote systems:


$Servers = "Win2012Svr1", "Win2012Svr2","Win2012Svr3"

$Servers |%{
Invoke-Command {
$action = New-ScheduledTaskAction -Execute 'C:TaskClientStatsClientStats.bat'

$trigger =  New-ScheduledTaskTrigger -Daily -At 1am

Register-ScheduledTask -Action $action -Trigger $trigger -TaskName "ClientStats" -Description "Daily Stat Dump" -user "domainadmin" -password "adminpassword1" -runlevel Highest
} -ComputerName $_





Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: