PowerShell Logo Small

Get-JobTrigger



This is the built-in help made by Microsoft for the command 'Get-JobTrigger', in PowerShell version 4 - as retrieved from Windows version 'Microsoft Windows 8.1 Enterprise' PowerShell help files on 2016-06-23.

For PowerShell version 3 and up, where you have Update-Help, this command was run just before creating the web pages from the help files.

SYNOPSIS

Gets the job triggers of scheduled jobs.

SYNTAX


Get-JobTrigger [-InputObject] <ScheduledJobDefinition> [[-TriggerId] <Int32[]>] [<CommonParameters>]
Get-JobTrigger [-Id] <Int32> [[-TriggerId] <Int32[]>] [<CommonParameters>]
Get-JobTrigger [-Name] <String> [[-TriggerId] <Int32[]>] [<CommonParameters>]



Search powershellhelp.space

DESCRIPTION


The Get-JobTrigger cmdlet gets the job triggers of scheduled jobs. You can use this command to examine the job triggers or to pipe the job triggers to other cmdlets.


A "job trigger" defines a recurring schedule or conditions for starting a scheduled job. Job triggers are not saved to disk independently; they are part of a schedule
d job. To get a job trigger, specify the scheduled job that the trigger starts.


Use the parameters of the Get-JobTrigger cmdlet to identify the scheduled jobs. You can identify the scheduled jobs by their names or identification numbers, or by en
tering or piping ScheduledJob objects, such as the those that are returned by the Get-ScheduledJob cmdlet, to Get-JobTrigger.


Get-JobTrigger is one of a collection of job scheduling cmdlets in the PSScheduledJob module that is included in Windows PowerShell.


For more information about Scheduled Jobs, see the About topics in the PSScheduledJob module. Import the PSScheduledJob module and then type: Get-Help about_Scheduled
* or see about_Scheduled_Jobs.


This cmdlet is introduced in Windows PowerShell 3.0.



<

RELATED LINKS

Online Version: http://go.microsoft.com/fwlink/p/?linkid=290625
about_Scheduled_Jobs
Add-JobTrigger
Disable-JobTrigger
Disable-ScheduledJob
Enable-JobTrigger
Enable-ScheduledJob
Get-JobTrigger
Get-ScheduledJob
Get-ScheduledJobOption
New-JobTrigger
New-ScheduledJobOption
Register-ScheduledJob
Remove-JobTrigger
Set-JobTrigger
Set-ScheduledJob
Set-ScheduledJobOption
Unregister-ScheduledJob

REMARKS

<

Examples


Example 1: Get a job trigger by scheduled job name

PS C:\>Get-JobTrigger -Name BackupJob



The command uses the Name parameter of Get-JobTrigger to get the job triggers of the BackupJob scheduled job.




Example 2: Get a job trigger by ID

The first command uses the Get-ScheduledJob cmdlet to display the scheduled jobs on the local computer. The display includes the IDs of the scheduled jobs.
PS C:\>Get-ScheduledJob
Id Name Triggers Command Enabled
-- ---- -------- ------- -------
1 ArchiveProjects {1} \\Server\Share\Archive-Projects.ps1 True
2 Backup {1,2} \\Server\Share\Run-Backup.ps1 True
3 Test-HelpFiles {1} \\Server\Share\Test-HelpFiles.ps1 True
4 TestJob {} \\Server\Share\Run-AllTests.ps1 True

The second command uses the Get-JobTrigger cmdlet to get the job trigger for the Test-HelpFiles job (ID = 3)
PS C:\>Get-JobTrigger -ID 3



The example uses the ID parameter of Get-JobTrigger to get the job triggers of a scheduled job.




Example 3: Get job triggers by piping a job

PS C:\>Get-ScheduledJob -Name *Backup*, *Archive* | Get-JobTrigger



This command gets the job triggers of all jobs that have "Backup" or "Archive" in their names.




Example 4: Get the job trigger of a job on a remote computer

PS C:\>Invoke-Command -ComputerName Server01 { Get-ScheduledJob Backup | Get-JobTrigger -TriggerID 2 }



This command gets one of the two job triggers of a scheduled job on a remote computer.

The command uses the Invoke-Command cmdlet to run a command on the Server01 computer. It uses the Get-ScheduledJob cmdlet to get the Backup scheduled job, which it pi
pes to the Get-JobTrigger cmdlet. It uses the TriggerID parameter to get only the second trigger.




Example 5: Get all job triggers

PS C:\>Get-ScheduledJob | Get-JobTrigger | For mat-Table -Property ID, Frequency, At, DaysOfWeek, Enabled, @{Label="ScheduledJob";Expression={$_.JobDefinition.Name}}
-AutoSize
Id Frequency At DaysOfWeek Enabled ScheduledJob
-- --------- -- ---------- ------- ------------
1 Weekly 9/28/2011 3:00:00 AM {Monday} True Backup
1 Daily 9/27/2011 11:00:00 PM True Test-HelpFiles



This command gets all job triggers of all scheduled jobs on the local computer.

The command uses the Get-ScheduledJob to get the scheduled jobs on the local computer and pipes them to Get-JobTrigger, which gets the job trigger of each scheduled j
ob (if any).

To add the name of the scheduled job to the job trigger display, the command uses the "calculated property" feature of the Format-Table cmdlet. In addition to the job
trigger properties that are displayed by default, the command creates a new "ScheduledJob" property that displays the name of the scheduled job.




Example 6: Get the job trigger property of a scheduled job

The command uses the Get-ScheduledJob cmdlet to get the Test-HelpFiles scheduled job. Then it uses the dot method (.) to get the JobTriggers property of the Test-Help
Files scheduled job.
PS C:\>(Get-ScheduledJob Test-HelpFiles).JobTriggers

The second command uses the Get-ScheduledJob cmdlet to get all scheduled jobs on the local computer. It uses the Foreach-Object cmdlet to get the value of the JobTrig
ger property of each scheduled job.
PS C:\>Get-ScheduledJob | foreach {$_.JobTriggers}



The job triggers of a scheduled job are stored in the JobTriggers property of the job. This example shows alternatives to using the Get-JobTrigger cmdlet to get job t
riggers. The results are identical to using the Get-JobTrigger cmdlet and the techniques can be used interchangeably.




Example 7: Compare job triggers

The first command gets the job trigger of the ArchiveProjects scheduled job. The command pipes the job trigger to the Tee-Object cmdlet, which saves the job trigger i
n the $t1 variable and displays it at the command line.
PS C:\>Get-ScheduledJob -Name ArchiveProjects | Get-JobTrigger | Tee-Object -Variable t1
Id Frequency Time DaysOfWeek Enabled
-- --------- ---- ---------- -------
0 Daily 9/26/2011 3:00:00 AM True

The second command gets the job trigger of the Test-HelpFiles scheduled job. The command pipes the job trigger to the Tee-Object cmdlet, which saves the job trigger i
n the $t2 variable and displays it at the command line.
PS C:\>Get-ScheduledJob -Name Test-HelpFiles | Get-JobTrigger | Tee-Object -Variable t2
Id Frequency Time DaysOfWeek Enabled
-- --------- ---- ---------- -------
0 Daily 9/26/2011 3:00:00 AM True

The third command compares the job triggers in the $t1 and $t2 variables. It uses the Get-Member cmdlet to get the properties of the job trigger in the $t1 variable.
It pipes the properties to the ForEach-Object cmdlet, which compares each property to the properties of the job trigger in the $t2 variable by name. The command then
pipes the differing properties to the Format-List cmdlet, which displays them in a list.The output indicates that, although the job triggers appear to be the same, th
e HelpFiles job trigger includes a random delay of three (3) minutes.
PS C:\>$t1 | Get-Member -Type property | ForEach-Object { Compare-Object $t1 $t2 -Property $_.Name}
RandomDelay SideIndicator
----------- -------------
00:00:00 =>
00:03:00 <=



This example shows how to compare the job triggers of two scheduled jobs.