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

Powershell Script to use with mgmt_cli

Thought I would add this to show how to automate adding objects using a script on Windows machines.

1. create hosts.csv with two columns headed host ipv4 and color eg


2. Open powershell and cd to the Checkpoint mgmt_cli location

cd "C:\Program Files (x86)\CheckPoint\SmartConsole\R80\PROGRAM"

3. Edit the below to point to the location of your csv file.
Also edit the management server ip, username and password.  These could be passed as $variables ??

4. Paste all the below lines between ~#~#~  into a powershell.


$hosts = Import-csv c:\path\to\hosts.csv
#This will process the CSV row by row. Each row contains information to create ahost object with a name and ipv4-address
foreach ($node in $hosts)

   $name = $
   $ipv4 = $node.ipv4
   $color = $node.color
   #create hosts from csv file, management server (-m) username (-u) and password (-p) are required fields.
   .\mgmt_cli add host name $name ip-address $ipv4 color $color -m <MGMT_SERVER_HERE> -u <USER_HERE> -p <PASSWORD_HERE>


This will publish each line after every pass.

7 Replies

Did you know:  mgmt_cli can accept csv files as inputs using the --batch option.

The first row should contain the argument names and the rows below it should hold the values for these parameters.

So an equivalent solution to the powershell script could look like this:



mgmt_cli add host --batch data.csv -u <username> -p <password> -m <management server>

This can work with any type of command not just "add host" : simply replace the column names with the ones relevant to the command you need.


You can stream line the authentication elements of that script/command line with the "-s <session_id_file>" instead of having to provide "-u <username> -p <password> -m <management server>", like this:

mgmt_cli login user <smartconsole_administrator_name> -m <management server> > id.txt


mgmt_cli add host --batch data.csv -s id.txt


mgmt_cli publish -s id.txt

mgmt_cli logout -s id.txt

This will also then publish the changes and logout, closing that session, as it relates to the session id file.

mgmt_cli defaults to using the management server at or as defined by the environment variable "MGMT_CLI_MANAGEMENT".


No missed that, makes it even better and easier then Smiley Happy

I just wanted to show options for powershell as previous posts and scripts tend to be linux based.  Due to smartconsole on windows we should all have powershell to work with.

Not applicable

Love the API. Great forum. Thanks.


API documentation found in misc. forum posts is bad.

API without proper online documentation diminishes the power of the API

See for what APIs with documentation should look like.




Your feedback is probably best added here:  Management API reference where Yonatan Philip is asking for input.

0 Kudos

I tried to add all of the mgmt_cli commands into a file and execute but end up with following error:

Error: The parameters of login command should be provided in pairs (key and value). You have provided an odd number of parameters which suggests that you are probably missing a parameter.

If I copy and paste the same commands into cli it works fine??

0 Kudos
Employee Alumnus
Employee Alumnus

Can you please specify which commands and in which order?

Please be more specific and informative.

CLI window in SmartConsole works differently than mgmt_cli tool on the management server.


0 Kudos