Created
December 25, 2018 19:48
-
-
Save alevyinroc/780e8484669a2d36ed1095dfd06588e2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Export current jobs to scripts | |
| Get-DbaAgentJob -SqlInstance $OldInstance | Where-Object {-not $_.isenabled} | ForEach-Object {Export-DbaScript $_ -Path (Join-Path -Path s:\Temp\2016Migration\DisabledJobs -Childpath "$($_.name.replace('\','$')).sql")}; | |
| Get-DbaAgentJob -SqlInstance $OldInstance | Where-Object {$_.isenabled} | ForEach-Object {Export-DbaScript $_ -Path (Join-Path -Path s:\Temp\2016Migration\EnabledJobs -Childpath "$($_.name.replace('\','$')).sql")}; | |
| # Get only the enabled job | |
| $JobsToCopy = Get-DbaAgentJob -SqlInstance $OldInstance -ExcludeDisabledJobs; | |
| # Copy the Operator(s) from the existing server | |
| Copy-DbaAgentOperator -Source $oldinstance -Destination $newinstance; | |
| # Copy only the enabled jobs and disable on the new server | |
| Copy-DbaAgentJob -Source $OldInstance -Destination $NewInstance -Job $JobsToCopy.Name -verbose -DisableOnDestination; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment