- CheckMates
- :
- CheckMates Toolbox
- :
- Scripts
- :
- rename_objects.sh - bash script using CSV to bulk ...
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
rename_objects.sh - bash script using CSV to bulk rename objects (on MDS)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I've created a bash script to bulk rename objects listed in a CSV file. You need to run it on a MDS with the Management API enabled.
Features
- Auto-detect API version of MDS.
- Use CSV file for defining all objects to rename.
- Bulk rename of TCP service objects is supported.
- Bulk rename of UDP service objects is supported.
- Bulk rename of Hosts objects is supported.
- Bulk rename of Networks is supported.
- Bulk rename of Service Groups is supported.
- Bulk rename of Network Groups is supported.
- Auto publish or no publish after successfully renaming the objects.
- Auto discard complete session when return value of API call to rename object is not 0 (0=SUCCESS).
- Display errors/warnings when session is discarded.
CSV file
Create a seperate CSV file for each object type you want to rename. This means you cannot mix object types like TCP and UDP services into one CSV file. When running the script you have to specify which object type the CSV file contains.
Each CSV file has to start with a special line:
name,new-name
From that point you can add new lines with current name<comma>new name
Example CSV file with host objects:
name,new-name
Gooogle-DNS1,Google-DNS1
Googgle-DNS2,Google-DNS2
Script example
./rename_objects.sh johndoe DMS-CP-1 CHG4726 hosts rename_hosts.csv nopublish
This allows user johndoe to login to the domain DMS-CP-1. It will use changenumber CHG4726 for session name and description. Furthermore you tell that it will find host objects in the CSV file rename_hosts.csv. Last but not least the nopublish action will force a logout of the API session after succesfully renaming the objects. This will allow you to takeover the session in SmartConsole for manual verification and a manual publish if you're satisfied with the results.
Usage
Usage:
./rename_objects.sh [ARGUMENTS]...
Rename objects listed in a CSV file using the Management API of a Check Point
Multi-Domain Management Server running on R80.x
Mandatory arguments to supply when running the script.
username Put your username that has Write access to the DMS here.
domainname Put the name of the DMS here.
changenumber Put in your changenumber. It will be used for session info.
objecttype Can be either tcp|udp|hosts|networks|servicegroups|networkgroups.
filename The CSV file that lists the current and new names of the
objects.
sessionaction Can be either nopublish|publish.
Example:
./rename_objects.sh johndoe DMS-CP-1 CHG4726 hosts rename_hosts.csv nopublish
If there are errors or warnings when renaming objects the complete session will
be discarded. A log will be shown so you can fix it before trying again.
The CSV file should always start with this line:
name,new-name
From this point you can add new lines with the current name and the new name of
the objects:
Gooogle-DNS1,Google-DNS1
Googgle-DNS2,Google-DNS2
etc...
When you choose not to publish you can takeover the session in SmartConsole.
In SmartConsole you can then verify the changes and publish it manually.
You can download rename_objects.sh on your MDS using the following CLI one-liner:
curl_cli -o rename_objects.sh tools.checkpoint.engineer/rename_objects.sh && chmod +x rename_objects.sh
or in a browser:
https://tools.checkpoint.engineer/rename_objects.sh
GitHub repository: https://github.com/Rick-Hoppe/rename-objects
Changelog
0.1 Initial version
0.2 Added dos2unix to remove Windows formatting
Hi,
I've created a bash script to bulk rename objects listed in a CSV file. You need to run it on a MDS with the Management API enabled.
Features
- Auto-detect API version of MDS.
- Use CSV file for defining all objects to rename.
- Bulk rename of TCP service objects is supported.
- Bulk rename of UDP service objects is supported.
- Bulk rename of Hosts objects is supported.
- Bulk rename of Networks is supported.
- Bulk rename of Service Groups is supported.
- B
Disclaimer: Check Point does not provide maintenance services or technical or customer support for third party content provided on this Site, including in CheckMates Toolbox. See also our Third Party Software Disclaimer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @_khard ,
This script was specifically written for a Multi-Domain environment, but you can easily modify it to work on a single management server.
It probably will work if you modify line 273 to:
mgmt_cli login user "$1" > id.txt
Note: You still need to enter a (fake) domainname but it will not be used to login. To remove this it would require a lot more custom modifications.
Hi @_khard ,
This script was specifically written for a Multi-Domain environment, but you can easily modify it to work on a single management server.
It probably will work if you modify line 273 to:
mgmt_cli login user "$1" > id.txt
Note: You still need to enter a (fake) domainname but it will not be used to login. To remove this it would require a lot more custom modifications.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content


Nice work !
I have some more features how to further develop this script.
1. Iterate over all Domains on MDS and check if the object to be renamed is existing on all Domains, not only on specified as an argument. You can specify only one Domain, but if you dont, the script will rename it on all Domains.
2. Integrate Global Domain, if present.
3. Rename the network objects searched by the IP addresses (not via name).
4. Automatic detection of SMS or MDS.
Jozko Mrkvicka
Nice work !
I have some more features how to further develop this script.
1. Iterate over all Domains on MDS and check if the object to be renamed is existing on all Domains, not only on specified as an argument. You can specify only one Domain, but if you dont, the script will rename it on all Domains.
2. Integrate Global Domain, if present.
3. Rename the network objects searched by the IP addresses (not via name).
4. Automatic detection of SMS or MDS.
;