commands

^

Remove-DbaAgentSchedule

Author Sander Stad (@sqlstad), sqlstad.nl
Availability Windows, Linux, macOS

 

Want to see the source code for this command? Check out Remove-DbaAgentSchedule on GitHub.
Want to see the Bill Of Health for this command? Check out Remove-DbaAgentSchedule.

Synopsis

Removes job schedules.

Description

Removes the schedules that have passed through the pipeline.

If not used with a pipeline, Get-DbaAgentSchedule will be executed with the parameters provided and the returned schedules will be removed.

Syntax

Remove-DbaAgentSchedule
    [[-SqlInstance] <DbaInstanceParameter[]>]
    [[-SqlCredential] <PSCredential>]
    [[-Schedule] <String[]>]
    [[-ScheduleUid] <String[]>]
    [[-Id] <Int32[]>]
    [[-InputObject] <ScheduleBase[]>]
    [-EnableException]
    [-Force]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> Remove-DbaAgentSchedule -SqlInstance sql1 -Schedule weekly

Remove the schedule weekly.

Example: 2
PS C:\> Remove-DbaAgentSchedule -SqlInstance sql1 -Schedule weekly -Force

Remove the schedule weekly even if the schedule is being used by jobs.

Example: 3
PS C:\> Remove-DbaAgentSchedule -SqlInstance sql1 -Schedule daily, weekly

Remove multiple schedules.

Example: 4
PS C:\> Remove-DbaAgentSchedule -SqlInstance sql1, sql2, sql3 -Schedule daily, weekly

Remove the schedule on multiple servers for multiple schedules.

Example: 5
PS C:\> Get-DbaAgentSchedule -SqlInstance sql1 -Schedule sched1, sched2, sched3 | Remove-DbaAgentSchedule

Remove the schedules using a pipeline.

Example: 6
PS C:\> Remove-DbaAgentSchedule -SqlInstance sql1, sql2, sql3 -ScheduleUid 'bf57fa7e-7720-4936-85a0-87d279db7eb7'

Remove the schedules using the schedule uid.

Optional Parameters

-SqlInstance

The target SQL Server instance or instances. You must have sysadmin access and server version must be SQL Server version 2000 or greater.

Alias
Required False
Pipeline false
Default Value
-SqlCredential

Login to the target instance using alternative credentials. Accepts PowerShell credentials (Get-Credential). Windows Authentication, SQL Server Authentication, Active Directory - Password, and Active Directory - Integrated are all supported. For MFA support, please use Connect-DbaInstance.

Alias
Required False
Pipeline false
Default Value
-Schedule

The name of the job schedule. Please note that there can be several schedules with the same name. These differ then only in the Id or the ScheduleUid.

Alias Schedules,Name
Required False
Pipeline false
Default Value
-ScheduleUid

The unique identifier of the schedule.

Alias Uid
Required False
Pipeline false
Default Value
-Id

The Id of the schedule.

Alias
Required False
Pipeline false
Default Value
-InputObject

A collection of schedules (such as returned by Get-DbaAgentSchedule), to be removed.

Alias
Required False
Pipeline true (ByValue)
Default Value
-EnableException

By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message. This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables advanced scripting. Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own try/catch.

Alias
Required False
Pipeline false
Default Value False
-Force

Remove the schedules even if they where used in one or more jobs.

Alias
Required False
Pipeline false
Default Value False
-WhatIf

Shows what would happen if the command were to run. No actions are actually performed.

Alias wi
Required False
Pipeline false
Default Value
-Confirm

Prompts you for confirmation before executing any changing operations within the command.

Alias cf
Required False
Pipeline false
Default Value