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. 

 

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 from and Import to JAMS v6.0 or later:

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 (Folder) in JAMS v6.0 where you want the import to be placed
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.0 or later:


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:

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.0 or later 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