Udostępnij za pośrednictwem


Unregister-ScheduledJob

Deletes scheduled jobs on the local computer.

Składnia

Definition (Domyślna)

Unregister-ScheduledJob
    [-InputObject] <ScheduledJobDefinition[]>
    [-Force]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

DefinitionId

Unregister-ScheduledJob
    [-Id] <Int32[]>
    [-Force]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

DefinitionName

Unregister-ScheduledJob
    [-Name] <String[]>
    [-Force]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

Opis

The Unregister-ScheduledJob cmdlet deletes scheduled jobs from the local computer.

When it deletes or unregisters a scheduled job, Unregister-ScheduledJob deletes the directory for the scheduled job (in the $HOME\AppData\Local\Microsoft\Windows\PowerShell\ScheduledJobs directory), which contains the XML file that defines the scheduled job, the job execution history, and all job results. This action also deletes the job from Task Scheduler.

Unregister-ScheduledJob deletes only the scheduled jobs that are created by using the Register-ScheduledJob cmdlet. It does not delete scheduled jobs that are created in Task Scheduler.

You can use the parameters of Unregister-ScheduledJob to delete scheduled jobs by ID or name, or pipe scheduled jobs from Get-ScheduledJob to Unregister-ScheduledJob.

Unregister-ScheduledJob 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.

Przykłady

Example 1: Delete a scheduled job

Unregister-ScheduledJob TestJob

This command deletes the TestJob scheduled job on the local computer.

Example 2: Delete all scheduled jobs

Get-ScheduledJob | Unregister-ScheduledJob -Force
Unregister-ScheduledJob -Name "*" -Force

This example shows two different commands that delete all scheduled jobs on the local computer.

The first command uses the Get-ScheduledJob cmdlet to get all scheduled jobs on the local computer. A pipeline operator (|) sends the scheduled jobs to Unregister-ScheduleJob, which deletes them.

The second command uses the Name parameter of Unregister-ScheduledJob with a value of all (*) to delete all scheduled jobs.

Both commands use the Force parameter, which deletes a scheduled job even if an instance of the job is running.

Example 3: Delete a scheduled job on a remote computer

Invoke-Command -ComputerName "Server01" { Unregister-ScheduledJob -Name "Test*"}

This command deletes scheduled jobs with names that begin with Test on the Server01 remote computer. The command uses the Invoke-Command cmdlet to run the Unregister-ScheduledJob command on the Server02 computer.

Parametry

-Confirm

Prompts you for confirmation before running the cmdlet.

Właściwości parametru

Typ:SwitchParameter
Domyślna wartość:False
Obsługuje symbole wieloznaczne:False
DontShow:False
Aliasy:cf

Zestawy parametrów

(All)
Position:Named
Obowiązkowy:False
Wartość z potoku:False
Wartość z potoku według nazwy właściwości:False
Wartość z pozostałych argumentów:False

-Force

Deletes the scheduled job even if an instance of the job is running. By default, Unregister-ScheduledJob does not interrupt running jobs.

Właściwości parametru

Typ:SwitchParameter
Domyślna wartość:None
Obsługuje symbole wieloznaczne:False
DontShow:False

Zestawy parametrów

(All)
Position:Named
Obowiązkowy:False
Wartość z potoku:False
Wartość z potoku według nazwy właściwości:False
Wartość z pozostałych argumentów:False

-Id

Deletes the scheduled jobs with the specified identification numbers (ID). Enter the IDs of scheduled jobs on the computer.

Właściwości parametru

Typ:

Int32[]

Domyślna wartość:None
Obsługuje symbole wieloznaczne:False
DontShow:False

Zestawy parametrów

DefinitionId
Position:0
Obowiązkowy:True
Wartość z potoku:False
Wartość z potoku według nazwy właściwości:False
Wartość z pozostałych argumentów:False

-InputObject

Specifies a scheduled job. 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 Unregister-JobTrigger.

Właściwości parametru

Typ:

ScheduledJobDefinition[]

Domyślna wartość:None
Obsługuje symbole wieloznaczne:False
DontShow:False

Zestawy parametrów

Definition
Position:0
Obowiązkowy:True
Wartość z potoku:True
Wartość z potoku według nazwy właściwości:False
Wartość z pozostałych argumentów:False

-Name

Deletes the scheduled jobs with the specified names. Enter the names of one or more scheduled jobs on the computer. Wildcards are supported.

Właściwości parametru

Typ:

String[]

Domyślna wartość:None
Obsługuje symbole wieloznaczne:False
DontShow:False

Zestawy parametrów

DefinitionName
Position:0
Obowiązkowy:True
Wartość z potoku:False
Wartość z potoku według nazwy właściwości:False
Wartość z pozostałych argumentów:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Właściwości parametru

Typ:SwitchParameter
Domyślna wartość:False
Obsługuje symbole wieloznaczne:False
DontShow:False
Aliasy:wi

Zestawy parametrów

(All)
Position:Named
Obowiązkowy:False
Wartość z potoku:False
Wartość z potoku według nazwy właściwości:False
Wartość z pozostałych argumentów: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.

Dane wejściowe

ScheduledJobDefinition

You can pipe a scheduled job to this cmdlet.

Dane wyjściowe

None

This cmdlet returns no output.