The Script Jobs module fully scripts out SQL Agent jobs. By default, Minion Enterprise scripts jobs to the Collector.DBObjectScripts table for all “Gold” level servers on a daily basis, “Silver” every three days, and “Bronze” every four weeks.


Note that you can also choose to script to files, default: C:\MinionByMidnightDBA\DBScriptBackups\.   For more information, see the section titled “Change the Default Location for Scripted Objects”. 

Like the Script Schemas module, this is an incredibly useful feature as a safeguard against changes and mistakes – such as a deleted job.

IMPORTANT: The SQL Agent service must be running to enable job scripting for an instance.

Table

Collector.DBObjectScripts

Holds the job scripts generated from each server, in addition to scripted objects from the Script Schemas module.

NOTE: This table is shared between the Script Jobs module and the Script Schemas module.
 
Column Type Description
ID bigint Primary key row identifier.
ExecutionDateTime datetime The execution date and time, common to the run of a collection for a single instance.
InstanceID bigint The instance ID of the instance in question, as defined in the table dbo.Servers.
DBName varchar Database name.
SchemaName varchar Schema name.
ObjectName varchar Object name.
ParentName varchar The object name of the current object’s parent. For example, a row for an index will have ParentName = the name of the owning table.
ObjectType varchar The object type. Note that the Script Jobs module scripts out jobs, so you should filter by ObjectType=’JOB’ for this module.
 
Example value:
JOB
Contents varchar The object CREATE or ALTER statement.
 

Views

Collector.DBObjectScriptsCurrent

Provides the most recent collections of scripted jobs and objects.

NOTE: This view is shared between the Script Jobs module and the Script Schemas module.

Each “Current” view associated with a Collector table contains all (or nearly all) of the columns from the base table, plus a “ViewDesc” description column, and columns from dbo.Servers data:
  • ServerName
  • ServiceLevel
  • Version
  • Edition
  • Descr

Collector.DBObjectScriptsPrevious

Provides the next-to-most recent collections of jobs and objects.

NOTE: This view is shared between the Script Jobs module and the Script Schemas module.

Each “Previous” view associated with a Collector table contains all (or nearly all) of the columns from the base table, plus a “ViewDesc” description column, and columns from dbo.Servers data:
  • ServerName
  • ServiceLevel
  • Version
  • Edition
  • Descr
 

Jobs

CollectorSQLJobScript -GOLD

Calls the executable JobScript.exe for all servers with ServiceLevel = ‘Gold’, to script out jobs.
 

CollectorSQLJobScript -SILVER

Calls the executable JobScript.exe for all servers with ServiceLevel = ‘Silver’, to script out jobs.
 

CollectorSQLJobScript-BRONZE

Calls the executable JobScript.exe for all servers with ServiceLevel = ‘Bronze’, to script out jobs.
 

Executables

JobScript.exe

Performs the script job collection for each managed server. Logs the results to the Collector.DBObjectScripts table, or to flat files, or both.

Input parameters:
  • $Query – This parameter refers to the service level that the collector should operate on. Examples: Gold, Silver, Bronze. For more information on this topic, see the article “Executables and Service Levels”.
  • $SaveToSQL – This parameter determines whether to save the job scripts to the SQL Server table Collector.DBObjectScripts. Valid values: 1, 0. By default, $SaveToSQL = 1.
  • $SaveToFile – This parameter determines whether to save the scripts to files. Valid values: 1, 0. By default, $SaveToFile is 0. If $SaveToFile is enabled, jobs are scripted out to files in C:\MinionByMidnightDBA\ServerName\DBName\ExecutionDateTime\Tables.
Example execution:
C:\MinionByMidnightDBA\Collector\JobScript.exe Gold 1 0
 

Script to files, tables, or both

You have the option of scripting your jobs to files, to a table, or both!  To change the Script Jobs behavior for “Gold” level servers, edit the script call in the “CollectorSQLJobScript-GOLD” job; the first parameter is always the service level; the second parameter is the Save to SQL bit; and the third parameter is the Save to File bit. 
  • To script jobs to files, edit the script call in the job “CollectorSQLJobScript-GOLD”: C:\MinionByMidnightDBA\Collector\JobScript.exe Gold 0 1
  • To script jobs to tables, edit the script call in the job “CollectorSQLJobScript-GOLD”: C:\MinionByMidnightDBA\Collector\JobScript.exe Gold 1 0
  • To script jobs to files and tables, edit the script call in the job “CollectorSQLJobScript-GOLD”: C:\MinionByMidnightDBA\Collector\JobScript.exe Gold 1 1

IMPORTANT: Be sure to use spaces between your parameters in the script call; do not use commas or other delimiters!

Of course, the same principles apply to the Silver and Bronze level jobs.

To disable all job scripting, disable the “CollectorSQLJobScript-%” jobs.

Make an exception for a single server

Minion Enterprise gives you the ability to make an exception for any server, for any collection, using the dbo.CollectionExceptionsServer table.  If Svr1 is a Gold level server, but you don’t want any job scripts generated for it, insert a row to dbo.CollectionExceptionsServer (using the InstanceID for Svr1 from dbo.Servers:

INSERT INTO dbo.CollectionExceptionsServer ( InstanceID, CollectionName )
VALUES  ( 99 , 'JobScript'  );
 
Now, InstanceID 99 (Svr1) will no longer take part in the Script Jobs collection!
 
https://minionware.desk.com/customer/portal/articles/2378817-script-jobs-module
http://www.MinionWare.net