<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic CLI API Example for exporting group members to a CSV file for later import in API / CLI Discussion</title>
    <link>https://community.checkpoint.com/t5/API-CLI-Discussion/CLI-API-Example-for-exporting-group-members-to-a-CSV-file-for/m-p/38841#M2336</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;H2&gt;Overview&lt;/H2&gt;&lt;P&gt;This set of example shell scripts for bash on Gaia, demonstrate how to export a CSV file containing all members of all groups (within the define limits value) with the show groups and show group command, and the requisite import operation using the generated CSV file to populate the existing groups with their respective members with the set group command utilizing the --batch &amp;lt;csv_input_file&amp;gt; optional switch.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H2&gt;Description&lt;/H2&gt;&lt;P&gt;Bash shell script "cli_api_dump_objects_group-members_build_import_csv_v00x01.sh" exports the members of the identified groups, first generating an array of groups based on the limit constraint value, and then using that array to dump the individual members of each group collected in the array to a CSV file with the first column being the group name and the second column being the group member.&amp;nbsp; The group members are selected from the output of "show groups" using the jq command, parsing the generated json output.&amp;nbsp; This script also generates an output file for process reference, in addition to the CSV file. and the console output.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Output files are generated as:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;CSV File :&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;Name:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; group-members-add_&lt;EM&gt;&amp;lt;DateTimeGroup&lt;/EM&gt;&amp;gt;.csv&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;Path:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dump/&lt;EM&gt;&amp;lt;DateTimeGroup&amp;gt;&lt;/EM&gt;/&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;Example:&amp;nbsp; dump/2016-06-30-1044CDT/group-members-add_2016-06-30-1044CDT.csv&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;Operations Output File:&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;Name:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; group-members_build_import_csv__&amp;lt;DateTimeGroup&amp;gt;.txt&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;Path:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dump/&lt;EM&gt;&amp;lt;DateTimeGroup&amp;gt;&lt;/EM&gt;/&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;Example:&amp;nbsp; dump/2016-06-30-1044CDT/group-members_build_import_csv_2016-06-30-1044CDT.txt&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example output CSV file group-members-add_2016-06-30-1044CDT.csv :&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;name,members.add&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;CP-Management,"R80-Demo-SMS-01"&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;CP-Management,"R80-Demo-SmartEvent"&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;CP-Gateways,"Perimeter-Jupiter-R77x30"&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;Management-Workstations,"Joe-Lenovo-W500"&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;Management-Workstations,"Hans-Dell-M4800"&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;Management-Workstations,"Madoka-Asus-X900"&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;Management-Workstations,"Terry-Apple-iBook"&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P&gt;Bash shell script "cli_api_import_objects_csv_group-members_v00x01.sh" imports a CSV file via the "set group" operation, using the columns of the CSV file to populate the group.&amp;nbsp; This script stipulates output from the shell script "cli_api_dump_objects_group-members_build_import_csv_v00x01.sh" or a similar CSV file that has the group name to set as the first column.&amp;nbsp; For this operation the expected action is that each member added to a group is the second value on a new row of the CSV file with the target group's name as the first column.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is stipulated that the groups and member objects to populate the groups were created in a previous process before this Example&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The import operation will generate an output file with the json details of the "set" operation, which can be reviewed for errors during the import operation, since missing member objects or groups will not be handled.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Output files are generated as:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;Operations Output File:&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;Name:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dump_add_group-members_via_set_&amp;lt;DateTimeGroup&amp;gt;.json&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;Path:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dump/&lt;EM&gt;&amp;lt;DateTimeGroup&amp;gt;&lt;/EM&gt;/&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;Example:&amp;nbsp; dump/2016-06-30-1044CDT/dump_add_group-members_via_set_2016-06-30-1217CDT.json&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H2&gt;Instructions&lt;/H2&gt;&lt;P&gt;To utilize the Bash shell scripts, download and copy them to the target host, most likely the management server for the specific operation (export and/or import).&amp;nbsp; It may be wise to execute a dos2unix operation against the scripts to ensure they are no longer in DOS text format.&amp;nbsp; Tailoring the shell scripts can provide personalized control over root paths for target output and CSV files as well as any desired tweaks to file naming and operational output.&amp;nbsp; Executing each script will start with requiring authentication to the SmartConsole administrator account used for the mgmt_cli operations, set with variable "&lt;EM&gt;&lt;STRONG&gt;APICLIadmin&lt;/STRONG&gt;&lt;/EM&gt;"; successful authentication starts the process of output generation or import of the identified CSV file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To generate the required CSV file with groups and group members, execute the "cli_api_dump_objects_group-members_build_import_csv_v00x01.sh" script on the management server that has the groups with members to export.&amp;nbsp; The export will handle up to the defined limit number of groups as defined in the variable "&lt;EM&gt;&lt;STRONG&gt;APICLIObjectLimit&lt;/STRONG&gt;&lt;/EM&gt;", which can be modified to suite testing or complete execution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NOTE:&amp;nbsp; the array population with the groups is a quiet process without visible action, so patience is advised when specifying a large value for the variable "&lt;EM&gt;&lt;STRONG&gt;APICLIObjectLimit&lt;/STRONG&gt;&lt;/EM&gt;".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Transfer the generated CSV file to the target management server that will import the group members.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Execute the "cli_api_import_objects_csv_group-members_v00x01.sh" script with the generated CSV (identified with variable "&lt;EM&gt;&lt;STRONG&gt;CSVImportPathFile&lt;/STRONG&gt;&lt;/EM&gt;") in the expected directory (identified with variable "&lt;EM&gt;&lt;STRONG&gt;CSVImportPathRoot&lt;/STRONG&gt;&lt;/EM&gt;")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H2&gt;Configuration&lt;/H2&gt;&lt;P&gt;These script examples attempt to provide some detail tailoring and configuration via variables set for the specific script.&amp;nbsp; This version does not make the approach overly generic (e.g. name of exported CSV file is hardcode in the import), and future versions of this example set may clearly abstract and configure command line input variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Key values to configure for:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;Both Export and Import&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="border: 1px solid #c6c6c6; width: 100%;"&gt;&lt;TBODY style="padding-left: 30px;"&gt;&lt;TR&gt;&lt;TH style="text-align: left; background-color: #f2f2f2; color: #505050; padding: 6px;" valign="middle"&gt;&lt;STRONG&gt;Variable&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: left; background-color: #f2f2f2; color: #505050; padding: 6px;" valign="middle"&gt;&lt;STRONG&gt;Definition&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;&lt;EM&gt;&lt;STRONG&gt;APICLIadmin&lt;/STRONG&gt;&lt;/EM&gt;&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;SmartConsole administrator name to use for operations&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;&lt;EM&gt;&lt;STRONG&gt;APICLIsessionfile&lt;/STRONG&gt;&lt;/EM&gt;&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;filename and path to mgmt_cli session ID file generated by login and used for all subsequent mgmt_cli operations&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Export&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="border: 1px solid #c6c6c6; width: 100%;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: left; background-color: #f2f2f2; color: #505050; padding: 6px;" valign="middle"&gt;&lt;STRONG&gt;Variable&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: left; background-color: #f2f2f2; color: #505050; padding: 6px;" valign="middle"&gt;&lt;STRONG&gt;&lt;STRONG&gt;Definition&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD colspan="1" style="padding: 6px;"&gt;&lt;EM&gt;&lt;STRONG&gt;APICLIpathroot&lt;/STRONG&gt;&lt;/EM&gt;&lt;/TD&gt;&lt;TD colspan="1" style="padding: 6px;"&gt;root of path for output files&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;&lt;EM&gt;&lt;STRONG&gt;APICLIpathbase&lt;/STRONG&gt;&lt;/EM&gt;&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;base path for output files, generally uses &lt;EM&gt;&lt;STRONG&gt;$APICLIpathroot&lt;/STRONG&gt;&lt;/EM&gt; and for operations time delineation can utilize the $DATE variable&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;&lt;EM&gt;&lt;STRONG&gt;APICLIfileoutputpre&lt;/STRONG&gt;&lt;/EM&gt;&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;General prefix for the output file, prefixes the filename in the full output file path&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;&lt;EM&gt;&lt;STRONG&gt;APICLIfileoutputext&lt;/STRONG&gt;&lt;/EM&gt;&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;File extension for operational output file, default is .txt&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;&lt;EM&gt;&lt;STRONG&gt;APICLIfileoutputsufix&lt;/STRONG&gt;&lt;/EM&gt;&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;File suffix for the operational output file, default is $DATE.&lt;STRONG&gt;&lt;EM&gt;$APICLIfileoutputext&lt;/EM&gt;&lt;/STRONG&gt; so generally&amp;lt;date_time_group&amp;gt;.txt&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;&lt;EM&gt;&lt;STRONG&gt;APICLIJSONfileoutputext&lt;/STRONG&gt;&lt;/EM&gt;&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;&lt;P&gt;File extension for mgmt_cli json output file, default is .json&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;NOTE:&lt;/STRONG&gt;&amp;nbsp; this is not used in this example&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;&lt;EM&gt;&lt;STRONG&gt;APICLIJSONfileoutputsufix&lt;/STRONG&gt;&lt;/EM&gt;&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;&lt;P&gt;File suffix for the mgmt_cli json output file, default is $DATE.&lt;EM&gt;&lt;STRONG&gt;$APICLIJSONfileoutputext&lt;/STRONG&gt;&lt;/EM&gt; so generally&amp;lt;date_time_group&amp;gt;.json&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;NOTE:&lt;/STRONG&gt;&amp;nbsp; this is not used in this example&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;&lt;EM&gt;&lt;STRONG&gt;APICLICSVfileoutputext&lt;/STRONG&gt;&lt;/EM&gt;&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;File extension for generated CSV file, default is .csv&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;&lt;EM&gt;&lt;STRONG&gt;APICLICSVfileoutputsufix&lt;/STRONG&gt;&lt;/EM&gt;&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;&lt;P&gt;File suffix for the operational output file, default is $DATE.&lt;STRONG&gt;&lt;EM&gt;$APICLICSVfileoutputext&lt;/EM&gt;&lt;/STRONG&gt; so generally&amp;lt;date_time_group&amp;gt;.csv&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;NOTE&lt;/STRONG&gt;:&amp;nbsp; this was purposely done for the work utilizing this example, which stipulates a defined state of CSV output to export based on the time of execution.&amp;nbsp; For those wanting a generic approach, the value can be set to be more static and not include the $DATE value element.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;&lt;STRONG&gt;&lt;EM&gt;APICLIObjectLimit&lt;/EM&gt;&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;This is the maximum number of groups to export, providing the limit value for the mgmt_cli show groups command to populate the array of groups to export members from.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;&lt;EM&gt;&lt;STRONG&gt;APICLIoutput&lt;/STRONG&gt;&lt;/EM&gt;&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;full file path to operational output file for later review of actions&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;Import&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="border: 1px solid #c6c6c6; width: 100%;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: left; background-color: #f2f2f2; color: #505050; padding: 6px;" valign="middle"&gt;&lt;STRONG&gt;Header 1&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: left; background-color: #f2f2f2; color: #505050; padding: 6px;" valign="middle"&gt;&lt;STRONG&gt;Header 2&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;&lt;EM&gt;&lt;STRONG&gt;APICLIfileoutputpre&lt;/STRONG&gt;&lt;/EM&gt;&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;General prefix for the output file, prefixes the filename in the full output file path&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;&lt;EM&gt;&lt;STRONG&gt;APICLIfileoutputext&lt;/STRONG&gt;&lt;/EM&gt;&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;File extension for mgmt_cli json output file, default is .json&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;&lt;EM&gt;&lt;STRONG&gt;APICLIfileoutputsufix&lt;/STRONG&gt;&lt;/EM&gt;&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;File suffix for the mgmt_cli json output file, default is $DATE.&lt;EM&gt;&lt;STRONG&gt;$APICLIfileoutputext&lt;/STRONG&gt;&lt;/EM&gt; so generally&amp;lt;date_time_group&amp;gt;.json&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;&lt;EM&gt;&lt;STRONG&gt;OutputPathRoot&lt;/STRONG&gt;&lt;/EM&gt;&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;root of path for output files&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;&lt;EM&gt;&lt;STRONG&gt;OutputPathBase&lt;/STRONG&gt;&lt;/EM&gt;&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;base path for output files, generally uses &lt;EM&gt;&lt;STRONG&gt;$OutputPathRoot&lt;/STRONG&gt;&lt;/EM&gt; and for operations time delineation can utilize the $DATE variable&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;&lt;EM&gt;&lt;STRONG&gt;CSVImportType&lt;/STRONG&gt;&lt;/EM&gt;&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;mgmt_cli type for import operation, in this example it is group&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;&lt;EM&gt;&lt;STRONG&gt;CSVImportPathRoot&lt;/STRONG&gt;&lt;/EM&gt;&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;This is the path root for the location of the CSV file to import, in the example it is a sub-directory relative to the location of the script&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;&lt;EM&gt;&lt;STRONG&gt;CSVImportPathFile&lt;/STRONG&gt;&lt;/EM&gt;&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;&lt;P&gt;This is the file name of the CSV file to import, in this case hard-coded based the CSV output generated by the export operation.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;NOTE&lt;/STRONG&gt;:&amp;nbsp; this was purposely done for the work utilizing this example, which stipulates a defined state of CSV output to import.&amp;nbsp; For those wanting a generic approach, the value can be set to be more static and not include the $DATE value element.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;&lt;EM&gt;&lt;STRONG&gt;CSVImportPath&lt;/STRONG&gt;&lt;/EM&gt;&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;This is the path to the CSV file to import based on the &lt;EM&gt;&lt;STRONG&gt;$CSVImportPathRoot&lt;/STRONG&gt;&lt;/EM&gt; and &lt;EM&gt;&lt;STRONG&gt;$CSVImportPathFile&lt;/STRONG&gt;&lt;/EM&gt; variables.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;&lt;EM&gt;&lt;STRONG&gt;OutputPath&lt;/STRONG&gt;&lt;/EM&gt;&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;full file path to operational output file for later review of actions&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Modification of the script sections to suit personal preference and requirements is strongly encouraged via the copy-paste operation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I may be updating these later, with some harmonization of common variables required and some abstraction options via command line parameters.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H2&gt;Why and What for...&lt;/H2&gt;&lt;P&gt;These scripts were developed to address a pressing need in my own basement cloud laboratory, after some issues cropped up with my migrated management server, which has an original data base starting from R70 and migrated, upgraded, imported to Multi-Domain Management, and now exported from Multi-Domain Management, which has left the system a bit wonky and questionable.&amp;nbsp; By creating scripts to handle the output of objects from my existing management server, I can then use the CSV data to import to a clean, new installation, where I can start fresh, with all my objects, but probably none of the baggage or garbage from almost 9 years of lab/home use operations.&amp;nbsp; It is an excellent learning opportunity and mentors like Uri Bialik help with this very much.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, these scripts can also help with some other operations that may be necessary, probably requiring some tweaks, but the example can help a bunch for starting out, operations like:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Duplicating group members after group import for laboratory environments, when building a from-scratch test environment, but wanting to use familiar objects&lt;/LI&gt;&lt;LI&gt;Duplicating group members after group import to a different Domain in Multi-Domain Management, when not wanting to use global objects.&amp;nbsp; This will require some adjustments to handle the Domain specification variables, but should not be rocket magic to make happen.&lt;/LI&gt;&lt;LI&gt;Operations in Professional Services for either recovering from an exported baseline, or assisting with pre-migration testing operations, and rebuild operations&lt;/LI&gt;&lt;LI&gt;Having a backup of objects on hand to utilize for bare-metal rebuild where a import or restore is not plausible or advisable.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;H2&gt;Code Version&lt;/H2&gt;&lt;P&gt;Code version 0.1.0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H2&gt;Tested on version&lt;/H2&gt;&lt;P&gt;R80, API version 1.0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: center;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN style="font-size: 13px; color: #ff0000;"&gt;&lt;STRONG&gt;NOTICE: &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.6667px; color: #999999;"&gt;&lt;STRONG&gt;By using this sample code you agree to terms and conditions in this &lt;A href="https://community.checkpoint.com/docs/DOC-1042"&gt;Not authorized to view the specified document 1042&lt;/A&gt;​&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: center;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;...&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 30 Jun 2016 20:30:13 GMT</pubDate>
    <dc:creator>Eric_Beasley</dc:creator>
    <dc:date>2016-06-30T20:30:13Z</dc:date>
    <item>
      <title>CLI API Example for exporting group members to a CSV file for later import</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/CLI-API-Example-for-exporting-group-members-to-a-CSV-file-for/m-p/38841#M2336</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;H2&gt;Overview&lt;/H2&gt;&lt;P&gt;This set of example shell scripts for bash on Gaia, demonstrate how to export a CSV file containing all members of all groups (within the define limits value) with the show groups and show group command, and the requisite import operation using the generated CSV file to populate the existing groups with their respective members with the set group command utilizing the --batch &amp;lt;csv_input_file&amp;gt; optional switch.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H2&gt;Description&lt;/H2&gt;&lt;P&gt;Bash shell script "cli_api_dump_objects_group-members_build_import_csv_v00x01.sh" exports the members of the identified groups, first generating an array of groups based on the limit constraint value, and then using that array to dump the individual members of each group collected in the array to a CSV file with the first column being the group name and the second column being the group member.&amp;nbsp; The group members are selected from the output of "show groups" using the jq command, parsing the generated json output.&amp;nbsp; This script also generates an output file for process reference, in addition to the CSV file. and the console output.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Output files are generated as:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;CSV File :&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;Name:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; group-members-add_&lt;EM&gt;&amp;lt;DateTimeGroup&lt;/EM&gt;&amp;gt;.csv&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;Path:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dump/&lt;EM&gt;&amp;lt;DateTimeGroup&amp;gt;&lt;/EM&gt;/&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;Example:&amp;nbsp; dump/2016-06-30-1044CDT/group-members-add_2016-06-30-1044CDT.csv&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;Operations Output File:&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;Name:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; group-members_build_import_csv__&amp;lt;DateTimeGroup&amp;gt;.txt&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;Path:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dump/&lt;EM&gt;&amp;lt;DateTimeGroup&amp;gt;&lt;/EM&gt;/&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;Example:&amp;nbsp; dump/2016-06-30-1044CDT/group-members_build_import_csv_2016-06-30-1044CDT.txt&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example output CSV file group-members-add_2016-06-30-1044CDT.csv :&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;name,members.add&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;CP-Management,"R80-Demo-SMS-01"&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;CP-Management,"R80-Demo-SmartEvent"&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;CP-Gateways,"Perimeter-Jupiter-R77x30"&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;Management-Workstations,"Joe-Lenovo-W500"&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;Management-Workstations,"Hans-Dell-M4800"&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;Management-Workstations,"Madoka-Asus-X900"&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;Management-Workstations,"Terry-Apple-iBook"&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P&gt;Bash shell script "cli_api_import_objects_csv_group-members_v00x01.sh" imports a CSV file via the "set group" operation, using the columns of the CSV file to populate the group.&amp;nbsp; This script stipulates output from the shell script "cli_api_dump_objects_group-members_build_import_csv_v00x01.sh" or a similar CSV file that has the group name to set as the first column.&amp;nbsp; For this operation the expected action is that each member added to a group is the second value on a new row of the CSV file with the target group's name as the first column.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is stipulated that the groups and member objects to populate the groups were created in a previous process before this Example&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The import operation will generate an output file with the json details of the "set" operation, which can be reviewed for errors during the import operation, since missing member objects or groups will not be handled.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Output files are generated as:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;Operations Output File:&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;Name:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dump_add_group-members_via_set_&amp;lt;DateTimeGroup&amp;gt;.json&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;Path:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dump/&lt;EM&gt;&amp;lt;DateTimeGroup&amp;gt;&lt;/EM&gt;/&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;Example:&amp;nbsp; dump/2016-06-30-1044CDT/dump_add_group-members_via_set_2016-06-30-1217CDT.json&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H2&gt;Instructions&lt;/H2&gt;&lt;P&gt;To utilize the Bash shell scripts, download and copy them to the target host, most likely the management server for the specific operation (export and/or import).&amp;nbsp; It may be wise to execute a dos2unix operation against the scripts to ensure they are no longer in DOS text format.&amp;nbsp; Tailoring the shell scripts can provide personalized control over root paths for target output and CSV files as well as any desired tweaks to file naming and operational output.&amp;nbsp; Executing each script will start with requiring authentication to the SmartConsole administrator account used for the mgmt_cli operations, set with variable "&lt;EM&gt;&lt;STRONG&gt;APICLIadmin&lt;/STRONG&gt;&lt;/EM&gt;"; successful authentication starts the process of output generation or import of the identified CSV file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To generate the required CSV file with groups and group members, execute the "cli_api_dump_objects_group-members_build_import_csv_v00x01.sh" script on the management server that has the groups with members to export.&amp;nbsp; The export will handle up to the defined limit number of groups as defined in the variable "&lt;EM&gt;&lt;STRONG&gt;APICLIObjectLimit&lt;/STRONG&gt;&lt;/EM&gt;", which can be modified to suite testing or complete execution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NOTE:&amp;nbsp; the array population with the groups is a quiet process without visible action, so patience is advised when specifying a large value for the variable "&lt;EM&gt;&lt;STRONG&gt;APICLIObjectLimit&lt;/STRONG&gt;&lt;/EM&gt;".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Transfer the generated CSV file to the target management server that will import the group members.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Execute the "cli_api_import_objects_csv_group-members_v00x01.sh" script with the generated CSV (identified with variable "&lt;EM&gt;&lt;STRONG&gt;CSVImportPathFile&lt;/STRONG&gt;&lt;/EM&gt;") in the expected directory (identified with variable "&lt;EM&gt;&lt;STRONG&gt;CSVImportPathRoot&lt;/STRONG&gt;&lt;/EM&gt;")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H2&gt;Configuration&lt;/H2&gt;&lt;P&gt;These script examples attempt to provide some detail tailoring and configuration via variables set for the specific script.&amp;nbsp; This version does not make the approach overly generic (e.g. name of exported CSV file is hardcode in the import), and future versions of this example set may clearly abstract and configure command line input variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Key values to configure for:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;Both Export and Import&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="border: 1px solid #c6c6c6; width: 100%;"&gt;&lt;TBODY style="padding-left: 30px;"&gt;&lt;TR&gt;&lt;TH style="text-align: left; background-color: #f2f2f2; color: #505050; padding: 6px;" valign="middle"&gt;&lt;STRONG&gt;Variable&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: left; background-color: #f2f2f2; color: #505050; padding: 6px;" valign="middle"&gt;&lt;STRONG&gt;Definition&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;&lt;EM&gt;&lt;STRONG&gt;APICLIadmin&lt;/STRONG&gt;&lt;/EM&gt;&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;SmartConsole administrator name to use for operations&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;&lt;EM&gt;&lt;STRONG&gt;APICLIsessionfile&lt;/STRONG&gt;&lt;/EM&gt;&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;filename and path to mgmt_cli session ID file generated by login and used for all subsequent mgmt_cli operations&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Export&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="border: 1px solid #c6c6c6; width: 100%;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: left; background-color: #f2f2f2; color: #505050; padding: 6px;" valign="middle"&gt;&lt;STRONG&gt;Variable&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: left; background-color: #f2f2f2; color: #505050; padding: 6px;" valign="middle"&gt;&lt;STRONG&gt;&lt;STRONG&gt;Definition&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD colspan="1" style="padding: 6px;"&gt;&lt;EM&gt;&lt;STRONG&gt;APICLIpathroot&lt;/STRONG&gt;&lt;/EM&gt;&lt;/TD&gt;&lt;TD colspan="1" style="padding: 6px;"&gt;root of path for output files&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;&lt;EM&gt;&lt;STRONG&gt;APICLIpathbase&lt;/STRONG&gt;&lt;/EM&gt;&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;base path for output files, generally uses &lt;EM&gt;&lt;STRONG&gt;$APICLIpathroot&lt;/STRONG&gt;&lt;/EM&gt; and for operations time delineation can utilize the $DATE variable&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;&lt;EM&gt;&lt;STRONG&gt;APICLIfileoutputpre&lt;/STRONG&gt;&lt;/EM&gt;&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;General prefix for the output file, prefixes the filename in the full output file path&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;&lt;EM&gt;&lt;STRONG&gt;APICLIfileoutputext&lt;/STRONG&gt;&lt;/EM&gt;&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;File extension for operational output file, default is .txt&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;&lt;EM&gt;&lt;STRONG&gt;APICLIfileoutputsufix&lt;/STRONG&gt;&lt;/EM&gt;&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;File suffix for the operational output file, default is $DATE.&lt;STRONG&gt;&lt;EM&gt;$APICLIfileoutputext&lt;/EM&gt;&lt;/STRONG&gt; so generally&amp;lt;date_time_group&amp;gt;.txt&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;&lt;EM&gt;&lt;STRONG&gt;APICLIJSONfileoutputext&lt;/STRONG&gt;&lt;/EM&gt;&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;&lt;P&gt;File extension for mgmt_cli json output file, default is .json&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;NOTE:&lt;/STRONG&gt;&amp;nbsp; this is not used in this example&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;&lt;EM&gt;&lt;STRONG&gt;APICLIJSONfileoutputsufix&lt;/STRONG&gt;&lt;/EM&gt;&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;&lt;P&gt;File suffix for the mgmt_cli json output file, default is $DATE.&lt;EM&gt;&lt;STRONG&gt;$APICLIJSONfileoutputext&lt;/STRONG&gt;&lt;/EM&gt; so generally&amp;lt;date_time_group&amp;gt;.json&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;NOTE:&lt;/STRONG&gt;&amp;nbsp; this is not used in this example&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;&lt;EM&gt;&lt;STRONG&gt;APICLICSVfileoutputext&lt;/STRONG&gt;&lt;/EM&gt;&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;File extension for generated CSV file, default is .csv&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;&lt;EM&gt;&lt;STRONG&gt;APICLICSVfileoutputsufix&lt;/STRONG&gt;&lt;/EM&gt;&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;&lt;P&gt;File suffix for the operational output file, default is $DATE.&lt;STRONG&gt;&lt;EM&gt;$APICLICSVfileoutputext&lt;/EM&gt;&lt;/STRONG&gt; so generally&amp;lt;date_time_group&amp;gt;.csv&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;NOTE&lt;/STRONG&gt;:&amp;nbsp; this was purposely done for the work utilizing this example, which stipulates a defined state of CSV output to export based on the time of execution.&amp;nbsp; For those wanting a generic approach, the value can be set to be more static and not include the $DATE value element.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;&lt;STRONG&gt;&lt;EM&gt;APICLIObjectLimit&lt;/EM&gt;&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;This is the maximum number of groups to export, providing the limit value for the mgmt_cli show groups command to populate the array of groups to export members from.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;&lt;EM&gt;&lt;STRONG&gt;APICLIoutput&lt;/STRONG&gt;&lt;/EM&gt;&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;full file path to operational output file for later review of actions&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;Import&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="border: 1px solid #c6c6c6; width: 100%;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: left; background-color: #f2f2f2; color: #505050; padding: 6px;" valign="middle"&gt;&lt;STRONG&gt;Header 1&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: left; background-color: #f2f2f2; color: #505050; padding: 6px;" valign="middle"&gt;&lt;STRONG&gt;Header 2&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;&lt;EM&gt;&lt;STRONG&gt;APICLIfileoutputpre&lt;/STRONG&gt;&lt;/EM&gt;&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;General prefix for the output file, prefixes the filename in the full output file path&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;&lt;EM&gt;&lt;STRONG&gt;APICLIfileoutputext&lt;/STRONG&gt;&lt;/EM&gt;&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;File extension for mgmt_cli json output file, default is .json&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;&lt;EM&gt;&lt;STRONG&gt;APICLIfileoutputsufix&lt;/STRONG&gt;&lt;/EM&gt;&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;File suffix for the mgmt_cli json output file, default is $DATE.&lt;EM&gt;&lt;STRONG&gt;$APICLIfileoutputext&lt;/STRONG&gt;&lt;/EM&gt; so generally&amp;lt;date_time_group&amp;gt;.json&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;&lt;EM&gt;&lt;STRONG&gt;OutputPathRoot&lt;/STRONG&gt;&lt;/EM&gt;&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;root of path for output files&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;&lt;EM&gt;&lt;STRONG&gt;OutputPathBase&lt;/STRONG&gt;&lt;/EM&gt;&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;base path for output files, generally uses &lt;EM&gt;&lt;STRONG&gt;$OutputPathRoot&lt;/STRONG&gt;&lt;/EM&gt; and for operations time delineation can utilize the $DATE variable&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;&lt;EM&gt;&lt;STRONG&gt;CSVImportType&lt;/STRONG&gt;&lt;/EM&gt;&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;mgmt_cli type for import operation, in this example it is group&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;&lt;EM&gt;&lt;STRONG&gt;CSVImportPathRoot&lt;/STRONG&gt;&lt;/EM&gt;&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;This is the path root for the location of the CSV file to import, in the example it is a sub-directory relative to the location of the script&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;&lt;EM&gt;&lt;STRONG&gt;CSVImportPathFile&lt;/STRONG&gt;&lt;/EM&gt;&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;&lt;P&gt;This is the file name of the CSV file to import, in this case hard-coded based the CSV output generated by the export operation.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;NOTE&lt;/STRONG&gt;:&amp;nbsp; this was purposely done for the work utilizing this example, which stipulates a defined state of CSV output to import.&amp;nbsp; For those wanting a generic approach, the value can be set to be more static and not include the $DATE value element.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;&lt;EM&gt;&lt;STRONG&gt;CSVImportPath&lt;/STRONG&gt;&lt;/EM&gt;&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;This is the path to the CSV file to import based on the &lt;EM&gt;&lt;STRONG&gt;$CSVImportPathRoot&lt;/STRONG&gt;&lt;/EM&gt; and &lt;EM&gt;&lt;STRONG&gt;$CSVImportPathFile&lt;/STRONG&gt;&lt;/EM&gt; variables.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;&lt;EM&gt;&lt;STRONG&gt;OutputPath&lt;/STRONG&gt;&lt;/EM&gt;&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;full file path to operational output file for later review of actions&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Modification of the script sections to suit personal preference and requirements is strongly encouraged via the copy-paste operation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I may be updating these later, with some harmonization of common variables required and some abstraction options via command line parameters.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H2&gt;Why and What for...&lt;/H2&gt;&lt;P&gt;These scripts were developed to address a pressing need in my own basement cloud laboratory, after some issues cropped up with my migrated management server, which has an original data base starting from R70 and migrated, upgraded, imported to Multi-Domain Management, and now exported from Multi-Domain Management, which has left the system a bit wonky and questionable.&amp;nbsp; By creating scripts to handle the output of objects from my existing management server, I can then use the CSV data to import to a clean, new installation, where I can start fresh, with all my objects, but probably none of the baggage or garbage from almost 9 years of lab/home use operations.&amp;nbsp; It is an excellent learning opportunity and mentors like Uri Bialik help with this very much.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, these scripts can also help with some other operations that may be necessary, probably requiring some tweaks, but the example can help a bunch for starting out, operations like:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Duplicating group members after group import for laboratory environments, when building a from-scratch test environment, but wanting to use familiar objects&lt;/LI&gt;&lt;LI&gt;Duplicating group members after group import to a different Domain in Multi-Domain Management, when not wanting to use global objects.&amp;nbsp; This will require some adjustments to handle the Domain specification variables, but should not be rocket magic to make happen.&lt;/LI&gt;&lt;LI&gt;Operations in Professional Services for either recovering from an exported baseline, or assisting with pre-migration testing operations, and rebuild operations&lt;/LI&gt;&lt;LI&gt;Having a backup of objects on hand to utilize for bare-metal rebuild where a import or restore is not plausible or advisable.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;H2&gt;Code Version&lt;/H2&gt;&lt;P&gt;Code version 0.1.0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H2&gt;Tested on version&lt;/H2&gt;&lt;P&gt;R80, API version 1.0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: center;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN style="font-size: 13px; color: #ff0000;"&gt;&lt;STRONG&gt;NOTICE: &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.6667px; color: #999999;"&gt;&lt;STRONG&gt;By using this sample code you agree to terms and conditions in this &lt;A href="https://community.checkpoint.com/docs/DOC-1042"&gt;Not authorized to view the specified document 1042&lt;/A&gt;​&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: center;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;...&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jun 2016 20:30:13 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/CLI-API-Example-for-exporting-group-members-to-a-CSV-file-for/m-p/38841#M2336</guid>
      <dc:creator>Eric_Beasley</dc:creator>
      <dc:date>2016-06-30T20:30:13Z</dc:date>
    </item>
  </channel>
</rss>

