Create a Post
cancel
Showing results for 
Search instead for 
Did you mean: 
Sagar_Manandhar
Advisor

Format of csv file to add object in group

Jump to solution

Hi,

I am trying to add the objects to the specific group using .csv file. I found " mgmt_cli set group --batch group-members_full_csv.csv" command from one of the SK but couldn't find the csv format. Has anybody done this, if yes please give me the format of .csv file.

Regards,
Sagar Manandhar

1 Solution

Accepted Solutions
masher
Employee
Employee

The full command for set group can be found at the following URL:

https://sc1.checkpoint.com/documents/latest/APIs/index.html#gui-cli/set-group~v1.1

The CSV should have the following header row:

name,members.add

The name field is for the group and the members.add field will be the host object to add to the group.

The rest of the body of the CSV would then be filled in as you wish:

group1,host1

group1,host2

group1,host3

group2,host1

group2,host2

group2,host3

You can then use the mgmt_cli command to run the batch job:

mgmt_cli -r true login > session.id

mgmt_cli -s session.id set group -b CSVFILE

mgmt_cli -s session.id publish

mgmt_cli -s session.id logout

View solution in original post

8 Replies
masher
Employee
Employee

The full command for set group can be found at the following URL:

https://sc1.checkpoint.com/documents/latest/APIs/index.html#gui-cli/set-group~v1.1

The CSV should have the following header row:

name,members.add

The name field is for the group and the members.add field will be the host object to add to the group.

The rest of the body of the CSV would then be filled in as you wish:

group1,host1

group1,host2

group1,host3

group2,host1

group2,host2

group2,host3

You can then use the mgmt_cli command to run the batch job:

mgmt_cli -r true login > session.id

mgmt_cli -s session.id set group -b CSVFILE

mgmt_cli -s session.id publish

mgmt_cli -s session.id logout

View solution in original post

Robert_Decker
Employee Alumnus
Employee Alumnus

Kudos for "members.add", not intuitive at all.

Robert.

Gaurav_Pandya
Advisor

Hi,

I have run the batch file but getting below error. 

csv format is like below

0 Kudos
Robert_Decker
Employee Alumnus
Employee Alumnus

does the file exist in your current workin directory?

0 Kudos
Gaurav_Pandya
Advisor

Hi Robert,

Ok. I have put my file in existing directory and it worked. I adjusted the setting of format and it worked.

Thanks for your support.

Rajesh_Metkar
Explorer

I think issue is because of _(underscore), use -(dash) instead

nbnaryal
Explorer

Hi masher, 

Thanks,  it really worked for me. It helped me to Block almost 120 IP addresses at once using this method.  The detailed procedure  of my task is mentioned below. Hope it can help others too.

Step 1 : Make the CSV file of object name and IP address in following format (filename =script1.csv)

name,ip-address
name1,xxx.xxx.xxx.xx
name1,xxx.xxx.xxx.xx
name1,xxx.xxx.xxx.xx

Login to the device through CLI
change the location to  tmp ( cd /tmp )
create a script file inside it ( vi Script1.csv )
paste the CSV file
to check whether the file is created or not paste (cat script.csv)
Run CSV file (mgmt_cli add host --batch script1.csv)
provide username and password

Step 2 : Make CSV file of Object group name and object name (filename = script2.csv)

name,members.add
groupname, name2
groupname, name2
groupname, name2


Login to device through CLI
change the location ot tmp ( cd /tmp )
create a script file inside it ( vi Script2.csv )
paste the csv file
to check weather the file is created of not paste (cat scrip2.csv)

mgmt_cli -r true login > session.id
mgmt_cli -s session.id set group -b script2.csv
mgmt_cli -s session.id publish
mgmt_cli -s session.id logout

If the locked session error is seen then try to publish and install the previous policies and logout/disconnect or takeover all the Read and write sessions and ten try Step 2

Refrences
https://www.youtube.com/watch?v=li4vRH63-_8
https://community.checkpoint.com/t5/Management/Format-of-csv-file-to-add-object-in-group/td-p/8987

Gaurav_Pandya
Advisor

Hi,

csv file would look like below.