Using the JAMS Export/Import PowerShell cmdlets

Follow

Users can export/import Jobs and other JAMS Objects, like Triggers and Variables, with the JAMS PowerShell Snap-in (Module) and its Export-JAMSXml and Import-JAMSXml cmdlets.  

This is handled slightly differently if you are using JAMS V6.X. Below are 2 sets of examples, depending on which version of JAMS users are exporting from and importing to. 


NOTE: Users cannot import V6 Jobs  and then import them to JAMS V7 with PowerShell. JAMS V7 Jobs cannot be exported to V6 with PowerShell. Use the built-in Conversion utility to convert V6 Jobs to JAMS V7


We recommend importing any resources, variables, users, queues, agenda and dates first. Import Jobs and then Setups. Triggers should be imported after Jobs and Setups. 

If you try to import a Job that references a User or Queue, it will not be able to create the Job without those objects already being in place and an error is displayed.


NOTE: Start PowerShell as a local administrator. You may encounter issues due to not having access to perform certain functions unless PowerShell is run as a local administrator. Right-click on the PowerShell shortcut and select Run As Administrator.


 

Export and Import from JAMS V7.X to JAMS V7.X


NOTE: Users cannot export from JAMS V7.X to JAMS V6.X, and cannot import to JAMS V7.X from JAMS V6.X.


Export Example:

#Import the JAMS Module
Import-Module JAMS
# Get a list of all Jobs in a Folder within JAMS
# Use -Objecttype (job,folder,variable) to specify the object type to export
# Use -IgnorePredefined to exclude the Predfined list of JAMS objects from the Management Group
# Use -FullObject to get the entire object, properties and elements included.
$job = Get-ChildItem JAMS::localhost\FolderName\* -objecttype Job -IgnorePredefined -FullObject
# Export all Jobs to XML
Export-JAMSXml C:\temp\file.xml $job

Import Example:

# Import Jobs, etc in XML to JAMS, first setting the location (JAMS Definitions Folder) 
# in JAMS v7.0 where you want the imported jobs to be placed
Import-Module JAMS
Set-Location JAMS::localhost\ FolderName \
$filepath = "c:\temp\file.xml"
Import-JAMSXml $filepath

Export from and Import to JAMS V6.X

Export example:

#Import the JAMS Module
Import-Module JAMS

# Get a list of all Jobs in a Folder within JAMS
# Use -Objecttype (job,setup,folder,variable) to specify the object type to export
# Use -IgnorePredefined to exclude the Predfined list of JAMS objects from the Management Group
$job = Get-ChildItem JAMS::localhost\FolderName\* -objecttype Job -IgnorePredefined # Export all Jobs to XML Export-JAMSXml C:\temp\file.xml $job

Import example:

# Import Jobs, etc in XML to JAMS, first setting the location (JAMS Definitions Folder) 
# in JAMS v6.0 where you want the imported jobs to be placed Import-Module JAMS
Set-Location JAMS::localhost\FolderName\ $filepath = "c:\temp\file.xml" Import-JAMSXml $filepath

 

 

Have more questions? Submit a request

Comments

  • Avatar
    Kirill Shiff

    Do you plan to have support for -Recurse option?

  • Avatar
    Gennaro Piccolo

    Hello Kirill,

    This is not needed for the export cmdlet as you can get all of the jobs you want to export with "Get-ChildItem \Folder\* -Recurse" then pass that as a variable containing the collection to Export-JAMSXml.

  • Avatar
    Jonathan Brune

    You mention loading resources, variables, etc. first. How does one export those? Are those different object types?

  • Avatar
    Dan Fowle

    Hello Jonathan,

    Yes, those are different JAMS objects, that can be found in the relevant shortcut in your JAMS Client (Resources, Queues, Agents). Variables are found within the Definitions area. In JAMS Version 7, each object should have an Export option either from the Object's properties window, or from a Right-Click context menu. In JAMS version 6.x, it was necessary to export via PowerShell.

  • Avatar
    Jonathan Brune

    Looks like Custom Execution methods need to be imported first as well.

  • Avatar
    Dan Fowle

    Hi Jonathan,

    That is also correct. Any supporting object that your job may reference (Users/Credentials as well) will need to be imported before the jobs will import successfully.

  • Avatar
    Sean Nolan

    To export a folder you need to get the folder with Get-Item, not Get-ChildItem, because Get-ChildItem will not include all the properties and parameters of the folder, so an example would be:

    $folder = Get-Item JAMS::localhost\FolderName

    # Export folder to XML
    Export-JAMSXml -Path C:\temp\folder.xml -InputObject $folder

  • Avatar
    Devkant Sharma

    How can we find out all resources (variables, queue, user etc.) on which my job is dependent on? My imports are often failing for this but don't give details as to which resource is missing in target environment where I am importing.

  • Avatar
    Gennaro Piccolo

    @DevKant, the XML export of the job will have all of the dependencies, so those must exist before importing the job. In JAMS v7, when importing an object, we added a tool tip that displays the error in the import dialogue screen.