Create SQL Agent job using SMO

# Powershell script to create a new Agent job and list the job using JobCollection # Inspects error collection and prints all inner exceptionfunction CheckForErrors{        $errorsReported = $False         if($Error.Count -ne 0)        {                write-host “******************************”                write-host “Errors:”, $Error.Count                 write-host “******************************”                foreach($err in $Error)                {                        $errorsReported  = $True                        if( $err.Exception.InnerException -ne $null)                        {                                write-host $err.Exception.InnerException.ToString()                        }                        else                        {                                write-host $err.Exception.ToString()                        }                        write-host “———————————————-”                }                throw        }} # Create a new job and get job back from…

1