Disable-ScheduledJob (PowerShell 3.0+)

Disable a scheduled job.

Syntax
      Disable-ScheduledJob [-InputObject] ScheduledJobDefinition
         [-PassThru] [-Confirm] [-WhatIf] [CommonParameters]

      Disable-ScheduledJob [-Id] Int32
         [-PassThru] [-Confirm] [-WhatIf] [CommonParameters]

      Disable-ScheduledJob [-Name] String
         [-PassThru] [-Confirm] [-WhatIf] [CommonParameters]

Key
   -Id Int32
       Disables the scheduled job with the specified identification number (ID).
       Enter the ID of a scheduled job.

   -InputObject ScheduledJobDefinition
       The scheduled job to be disabled.
       Enter a variable that contains ScheduledJobDefinition objects or type a
       command or expression that gets ScheduledJobDefinition objects, such as
       a Get-ScheduledJob command.
       You can also pipe a ScheduledJobDefinition object to Disable-ScheduledJob.

   -Name String
       Disables the scheduled jobs with the specified names.
       Enter the name of a scheduled job. Wildcards are supported.

   -PassThru
       Returns the scheduled jobs that were disabled.
       By default, this cmdlet does not generate any output.

   -Confirm
       Prompt for confirmation before running the cmdlet.

   -WhatIf
       Show what would happen if the cmdlet runs. The cmdlet is not run.

Disable-ScheduledJob cmdlet temporarily disables scheduled jobs. Disabling preserves all job properties and does not disable the job triggers, but it prevents the scheduled jobs from starting automatically when triggered.

You can start a disabled scheduled job by using the Start-Job cmdlet or use a disabled scheduled job as a template.

To disable a scheduled job, Disable-ScheduledJob sets the Enabled property of the scheduled job to False ($false).
To re-enable the scheduled job, use the Enable-ScheduledJob cmdlet.

Examples

Disable the scheduled job with ID 2 on the local computers:

PS C:\> Disable-ScheduledJob -ID 2 -Passthru

Disable all scheduled jobs:

PS C:\> Get-ScheduledJob | Disable-ScheduledJob -Passthru

Disable all scheduled jobs on the computers listed in Servers.txt The command uses Invoke-Command to run a Disable-ScheduleJob command on each remote computer:

PS C:\> Invoke-Command -ComputerName (Get-Content Servers.txt) -ScriptBlock {Disable-ScheduledJob -Name TestJob}

“New York is an exciting town where something is happening all the time, most unsolved” ~ Johnny Carson

Related PowerShell Cmdlets

Scheduler cmdlets - Get/Set scheduled jobs.
Enable-ScheduledJob - Enable a scheduled job.
Get-ScheduledJob - Get scheduled jobs on the local computer.


 
Copyright © 1999-2024 SS64.com
Some rights reserved