• I have a couple of powershell scripts which I can use to do this. I use them when I take over a role if there is little source control and just as a precaution. They are useful for migrations too.

    I forget where I got this one so I can't give credit to the initial author. I added a few modifications to it so...

    # Date: 23/02/12

    # Description: PS script to generate all SQL Server Agent jobs on the given instance.

    # The script accepts an input file of server names.

    # Version: 1.0

    #

    # Example Execution: .\Create_SQLAentJobSripts.ps1 .\ServerNameList.txt

    #param([String]$ServerListPath)

    #Load the input file into an Object array

    $ServerNameList = "";

    #get-content -path $ServerListPath

    $login = Read-Host 'Enter your SQL login'

    $password = Read-Host 'Enter your password' -AsSecureString;

    $BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($password);

    $PlainPassword = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR);

    #Load the SQL Server SMO Assemly

    [System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.Smo') | Out-Null

    #Create a new SqlConnection object

    $objSQLConnection = New-Object System.Data.SqlClient.SqlConnection

    #For each server in the array do the following..

    foreach($ServerName in $ServerNameList)

    {

    Try

    {

    #$objSQLConnection.ConnectionString = "Server=$ServerName;Integrated Security=SSPI;"

    $objSQLConnection.ConnectionString = "Server=$ServerName;User Id=$login;Password=$PlainPassword"

    Write-Host "Trying to connect to SQL Server instance on $ServerName..." -NoNewline

    $objSQLConnection.Open() | Out-Null

    Write-Host "Success."

    $objSQLConnection.Close()

    }

    Catch

    {

    Write-Host -BackgroundColor Red -ForegroundColor White "Fail"

    $errText = $Error[0].ToString()

    if ($errText.Contains("network-related"))

    {Write-Host "Connection Error. Check server name, port, firewall."}

    Write-Host $errText

    continue

    }

    #IF the output folder does not exist then create it

    $OutputFolder = "C:\Scripts\Jobs\$ServerName"

    $DoesFolderExist = Test-Path $OutputFolder

    $null = if (!$DoesFolderExist){MKDIR "$OutputFolder"}

    #Create a new SMO instance for this $ServerName

    $srv = New-Object "Microsoft.SqlServer.Management.Smo.Server" $objSQLConnection

    #Script out each SQL Server Agent Job for the server

    $srv.JobServer.Jobs | foreach {$job = $_.name -replace "\*", ""; $_.Script() | out-file "$OutputFolder\$job.sql"}

    }

    I'll need to try and find the other one. Its much easier to follow and uses SQLPSX.