File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ) {
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments