Remove-JobTrigger
Delete job triggers from scheduled jobs.
Syntaxe
JobDefinition (Výchozí)
Remove-JobTrigger
[-InputObject] <ScheduledJobDefinition[]>
[-TriggerId <Int32[]>]
[<CommonParameters>]
JobDefinitionName
Remove-JobTrigger
[-Name] <String[]>
[-TriggerId <Int32[]>]
[<CommonParameters>]
JobDefinitionId
Remove-JobTrigger
[-Id] <Int32[]>
[-TriggerId <Int32[]>]
[<CommonParameters>]
Description
The Remove-JobTrigger cmdlet deletes job triggers from scheduled jobs.
A job trigger defines a recurring schedule or conditions for starting a scheduled job. To manage job triggers, use the New-JobTrigger, Add-JobTrigger, Set-JobTrigger, and Set-ScheduledJob cmdlets.
Use the Name, ID, or InputObject parameters of Remove-JobTrigger to identify the scheduled jobs from which the triggers are removed. Use the TriggerID parameter to identify the job triggers to delete. By default, Remove-JobTrigger deletes all job triggers of a scheduled job.
Remove-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 was introduced in Windows PowerShell 3.0.
Příklady
Example 1: Delete all job triggers
PS C:\> Remove-JobTrigger -Name "Test*"
This command deletes all job triggers from scheduled job that have names that begin with Test.
Example 2: Delete selected job triggers
PS C:\> Remove-JobTrigger -Name "BackupArchive" -TriggerID 3
This command deletes only the third trigger (ID = 3) from the BackupArchive scheduled job.
Example 3: Delete AtStartup job triggers from all scheduled jobs
PS C:\> function Delete-AtStartup
{
Get-ScheduledJob | Get-JobTrigger | Where-Object {$_.Frequency -eq "AtStartup"} | ForEach-Object { Remove-JobTrigger -InputObject $_.JobDefinition -TriggerID $_.ID}
}
This function deletes all AtStartup job triggers from all jobs on the local computer.
To use the function, run the function in your session and then type Delete-AtStartup
.
The Delete-AtStartup function contains a single command. The command uses the Get-ScheduledJob cmdlet to get the scheduled jobs on the local computer. A pipeline operator (|) sends the scheduled jobs to the Get-JobTrigger cmdlet, which gets all of the job triggers from each of the scheduled jobs. A pipeline operator sends the job triggers to the Where-Object cmdlet, which selects job triggers where the value of the Frequency property of the job trigger equals AtStartup.
JobTrigger objects have a JobDefinition property that contains the scheduled job that they trigger. The remainder of the command uses that valuable feature.
A pipeline operator sends the AtStartup job triggers to the ForEach-Object cmdlet, which runs a Remove-JobTrigger command on each AtStartup trigger. The value of the InputObject parameter of Remove-JobTrigger is the scheduled job in the JobDefinition property of the job trigger. The value of the TriggerID parameter is the identifier in the ID property of the job trigger.
Example 4: Delete a job trigger from a remote scheduled job
PS C:\> Invoke-Command -ComputerName "Server01" { Remove-JobTrigger -ID 38 -TriggerID 1 }
This command deletes the first job trigger from the Inventory job on the Server01 computer.
The command uses the Invoke-Command cmdlet to run the Remove-JobTrigger cmdlet on the Server01 computer. The Remove-JobTrigger cmdlet uses the ID parameter to identify the Inventory scheduled job and the TriggerID parameter to specify the first trigger. The ID parameter is especially useful when multiple scheduled jobs have the same or similar names.
Parametry
-Id
Specifies the identification numbers of the scheduled jobs. Remove-JobTrigger deletes job triggers from the specified scheduled jobs.
To get the identification number of scheduled jobs on the local computer or a remote computer, use the Get-ScheduledJob cmdlet.
Vlastnosti parametru
Typ: | Int32[] |
Default value: | None |
Podporuje zástupné znaky: | False |
DontShow: | False |
Sady parametrů
JobDefinitionId
Position: | 0 |
Povinné: | True |
Hodnota z kanálu: | False |
Hodnota z kanálu podle názvu vlastnosti: | False |
Hodnota ze zbývajících argumentů: | False |
-InputObject
Specifies the scheduled jobs. Enter a variable that contains ScheduledJob objects or type a command or expression that gets ScheduledJob objects, such as a Get-ScheduledJob command. You can also pipe ScheduledJob objects to Remove-JobTrigger.
Vlastnosti parametru
Typ: | ScheduledJobDefinition[] |
Default value: | None |
Podporuje zástupné znaky: | False |
DontShow: | False |
Sady parametrů
JobDefinition
Position: | 0 |
Povinné: | True |
Hodnota z kanálu: | True |
Hodnota z kanálu podle názvu vlastnosti: | False |
Hodnota ze zbývajících argumentů: | False |
-Name
Specifies the names of the scheduled jobs. Remove-JobTrigger deletes the job triggers from the specified scheduled jobs. Wildcards are supported.
To get the names of scheduled jobs on the local computer or a remote computer, use the Get-ScheduledJob cmdlet.
Vlastnosti parametru
Typ: | String[] |
Default value: | None |
Podporuje zástupné znaky: | False |
DontShow: | False |
Sady parametrů
JobDefinitionName
Position: | 0 |
Povinné: | True |
Hodnota z kanálu: | False |
Hodnota z kanálu podle názvu vlastnosti: | False |
Hodnota ze zbývajících argumentů: | False |
-TriggerId
Deletes only the specified job triggers. By default, Remove-JobTrigger deletes all triggers from the scheduled jobs. Use this parameter when the scheduled jobs have multiple job triggers.
Enter the trigger IDs of one or more job triggers of a scheduled job. If you specify multiple scheduled jobs, Remove-JobTrigger deletes the job trigger with the specified ID from all scheduled jobs.
Vlastnosti parametru
Typ: | Int32[] |
Default value: | All triggers |
Podporuje zástupné znaky: | False |
DontShow: | False |
Sady parametrů
(All)
Position: | Named |
Povinné: | False |
Hodnota z kanálu: | False |
Hodnota z kanálu podle názvu vlastnosti: | False |
Hodnota ze zbývajících argumentů: | False |
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
Vstupy
ScheduledJobDefinition
You can pipe scheduled jobs to the Remove-JobTrigger cmdlet.
Výstupy
None
The cmdlet does not generate any output.
Související odkazy
- 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
- Where-Object