Created
June 19, 2021 09:39
-
-
Save ghotz/8eb13e498a9f57a2a235b11bbc4227fe to your computer and use it in GitHub Desktop.
Generate dbatools cmdlet calls to enable/disable jobs
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
| $Commands = @(); $Source = "oldsqlname"; $Destination = "newsqlname"; | |
| Get-DbaAgentJob -SqlInstance $Source | % { $Commands += "Set-DbaAgentJob -SqlInstance $Destination -Job `"$($_.Name)`" $(if ($_.Enabled) { `"-Enabled;`" } else { `"-Disabled;`" })" }; | |
| Write-Output @Commands |
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
| $Commands = @(); $Source = "oldsqlname"; $Destination = "newsqlname"; | |
| Get-DbaAgentJob -SqlInstance $Source | % { $Commands += "Set-DbaAgentJob -SqlInstance $Destination -Job `"$($_.Name)`" -Disabled;" }; | |
| Write-Output @Commands |
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
| $Commands = @(); $Source = "oldsqlname"; $Destination = "newsqlname"; | |
| Get-DbaAgentJob -SqlInstance $Source | % { $Commands += "Set-DbaAgentJob -SqlInstance $Destination -Job `"$($_.Name)`" $(if ($_.Enabled) { `"-Enabled;`" } else { `"-Disabled;`" })" }; | |
| Write-Output @Commands |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment