Richard Mason

Powershell Script to use with mgmt_cli

Discussion created by Richard Mason on May 9, 2016
Latest reply on Apr 8, 2018 by Robert Decker

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.