Skip to content

Commit 0332cfb

Browse files
Get-DbaAgentJob and Sync-DbaAvailabilityGroup: Move filter for MSX jobs to the command that needs it (#10198)
1 parent 91972b4 commit 0332cfb

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

public/Get-DbaAgentJob.ps1

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,6 @@ function Get-DbaAgentJob {
207207
if ($ExcludeDisabledJobs) {
208208
$jobs = $Jobs | Where-Object IsEnabled -eq $true
209209
}
210-
# Always exclude MSX jobs (CategoryID = 1) - they cannot be synced to secondary replicas
211-
$jobs = $jobs | Where-Object CategoryID -ne 1
212210
if ($Database) {
213211
$dbLookup = @{}
214212
foreach ($db in $Database) {

public/Sync-DbaAvailabilityGroup.ps1

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,6 @@ function Sync-DbaAvailabilityGroup {
374374

375375
if ($Exclude -notcontains "AgentJob") {
376376
Write-ProgressHelper -Activity $activity -StepNumber ($stepCounter++) -Message "Syncing Agent Jobs"
377-
# MSX jobs are automatically excluded by Get-DbaAgentJob to avoid errors
378377
$splatGetJob = @{
379378
SqlInstance = $server
380379
}
@@ -386,6 +385,9 @@ function Sync-DbaAvailabilityGroup {
386385
}
387386
$jobsToSync = Get-DbaAgentJob @splatGetJob
388387

388+
# Always exclude MSX jobs (CategoryID = 1) - they cannot be synced to secondary replicas
389+
$jobsToSync = $jobsToSync | Where-Object CategoryID -ne 1
390+
389391
$splatCopyJob = @{
390392
Destination = $secondaries
391393
Force = $force

0 commit comments

Comments
 (0)