Using the JAMS Export/Import PowerShell cmdlets

Follow

Users can export/import Jobs, Setups, Systems, Triggers, Variables, etc with the JAMS PowerShell Snap-in and its Export-JAMSXml and Import-JAMSXml cmdlets.  

This is handled slightly differently whether or not you are using JAMS v6.0 or not. Below are 4 sets of examples, depending on which version of JAMS users are exporting from and importing to. 

NOTE: Users cannot import V5 or V6 Jobs into JAMS V7 with PowerShell. JAMS V7 Jobs cannot be exported to V5 or V6 with PowerShell. Use the built-in Conversion utility to convert V6 Jobs to JAMS V7

We recommend importing any resources, variables, users, queues, agents, and dates first. Then systems(5.4 only), then jobs then setups.  Triggers should be imported after jobs and setups. 

 

The reason for this is that if you try to import a job that references a User or Queue for example, it will not be able to create the job without those objects already being in place, and users will receive an error.

 

Important to note:  Please start Powershell as a local administrator.  You may run into issues 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 nor JAMS V5.X, and cannot import to JAMS V7.X from JAMS V6.X nor JAMS V5.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

  

Export from JAMS v5.4 or earlier and Import to JAMS V6.X:


Export example:

 

#Import the JAMS Module
Import-Module JAMS

# Get a list of all Jobs in a JAMS System
$job = Get-ChildItem JAMS::localhost\Systems\JAMS\Jobs\*

# 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 (Folder) in JAMS v6.x where you want the import to be placed.  JAMS v6.x will ignore the <SystemName></SystemName>
# section of the export from v5.4 and will import in to the Folder specified in the Set-Location command below

#Import the JAMS Module
Import-Module JAMS

Set-Location JAMS::localhost\FolderName\
$filepath = "c:\temp\file.xml"
Import-JAMSXml $filepath

  

Export from and Import to JAMS v5.4 or earlier: 
NOTE:
Users cannot import V7 Jobs into JAMS V5.4.

Export example:

 

#Add the JAMS snapin
Add-pssnapin MVPSI.JAMS

# Get a list of all Jobs in a JAMS System
$job = Get-ChildItem JAMS::localhost\Systems\JAMS\Jobs\*

# Export all Jobs to XML
Export-JAMSXml C:\temp\file.xml $job

 

Import example:
 

#Add the JAMS snapin
Add-pssnapin MVPSI.JAMS

# Import Jobs, etc in XML to JAMS
$filepath = "c:\temp\file.xml"
Import-JAMSXml $filepath

 

Export from JAMS V6.X and Import to JAMS v5.4 or earlier:

Export example:
 

# Get a list of all Jobs in a Folder within JAMS
$job = Get-ChildItem JAMS::localhost\FolderName\*

# Export all Jobs to XML
Export-JAMSXml C:\temp\file.xml $job

 

Import example:

PLEASE NOTEYou will first need to edit the xml file that you exported to add the name of the System that the Job will be imported to in JAMS v5.4 or earlier.  To do this, edit the xml file in a text editor such as Notepad and add <SystemName>NameOfJAMSSystem</SystemName> as an additional attribute inside of the <Job></Job> section. 

The reference to a JAMS variable from a job parameter will also need to be changed.  In the V6 XML the variable will be referenced with a "\".  The backslash will need to be removed.

 

<VariableName>\VarName</VariableName>

Change to:

<VariableName>VarName</VariableName>

 

#Add the JAMS snapin
Add-pssnapin MVPSI.JAMS

# Import Jobs, etc in XML to JAMS
$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.