Monthly Archives: December 2017

Use WIndows Power Shell to Script SQL Jobs from one instance to another

Open Powershell Execute Invoke-Sqlcmd Execute $output = "d:\ScheduledJobs.sql" Execute Remove-Item $output Execute Set-Location SQLSERVER:\SQL\localhost\DEFAULT\JobServer\Jobs Execute # loop through jobs appending output Lastly Execute dir | %{$_.script() + "`n`nGO`n`n" | out-file -append $output} Do the above one line at a time … Continue reading

Posted in Uncategorized | Leave a comment