Powershell - Manually trigger a scheduled job

m.edmondson

I have created a powershell job that I can see when I use the following command:

PS C:\WINDOWS\system32> Get-ScheduledJob -Name KillTicker | Get-JobTrigger

Id         Frequency       Time                   DaysOfWeek              Enabled
--         ---------       ----                   ----------              -------
1          AtStartup                                                      True

As this is a startup job I really don't fancy restarting to test it out - how to do I manually start this job?

Martin Brandl

If you run Get-ScheduledJob -id 1 | Get-Member to retrieve all Members of a Microsoft.PowerShell.ScheduledJob.ScheduledJobDefinition you will see that the object expose a method called StartJob:

(Get-ScheduledJob -id 1).StartJob()

To retrieve the result, use the Receive-Job cmdlet:

Receive-Job -id 1

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related