Using cmdlets to create a new job requires planning as there is a lot information contained in a job definition. You would use cmdlets to automate a process, such as cloning a current job or creating a new job in an environment with limited resources.
[-Configuration] is the XML representation of the job or discovery configuration. See any of the job examples in the section, which discussed the Get-ERJobDefinition cmdlet. This is the best way to get a configuration to use in creating a job manually.
As you can see in this example, each section of the XML file has an opening and a closing statement. When you are working with a copy of the configuration from the Get-ERJobDefinition cmdlet, pay attention to spaces, text, slashes, and other characters, as missing or extra characters will cause an issue with the job.
The parameters in this example are formatted to make it easier for you to read. When running the cmdlet, the parameters cannot contain any carriage returns in the command line. If you want to use this example, you must first paste it into NotePad and remove the carriage returns.
In this example the configuration is in an XML file, which allows changes to be made to the configuration when using the cmdlets. The XML files are just simple files that can be edited using Notepad and do not require any special formatting. The configuration of any current job is in the XML format and can be used as a template.
In this example, you want to clone a current job. The important item to note is that the -Name parameter needs to be changed to a unique value. The first cmdlet Get-ERJobDefinition gets the data on the job you wish to clone. In the New-ERJobDefinition cmdlet you use the data in the configuration of the cloned job by using $JobDefinition.Configuration to supply the needed configuration for the new job.
Now that you have a job or two you need to run them to retrieve data from your environment by sending a job to the Enterprise Reporter server for immediate execution. Depending on what is processing within the server, the job may be queued to run at the next available time. This is different than scheduling a job which is discussed later.
In this example, the information about the job definition retrieved by the Get-ERJobDefinition cmdlet is piped to the Submit-ERJobDefinition cmdlet, so the job starts immediately. If the job starts, True is returned.
This is an example of a Run Once job set to start at a specific date and time. First, the job is placed into the $discovery variable using the Get-ERJobDefinition cmdlet. Second, the Set-ERJobDefinitionSchedule cmdlet is executed with a different time and date for the job. Note the single quote that encloses the time.
This is an example of a Run Monthly job set to start at a specific date and time on the 3rd Wednesday of the month.