<?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 Re: Powershell Script to use with mgmt_cli in API / CLI Discussion</title>
    <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Powershell-Script-to-use-with-mgmt-cli/m-p/2320#M74</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No missed that, makes it even better and easier then &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://community.checkpoint.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I just wanted to show options for powershell as previous posts and scripts tend to be linux based.&amp;nbsp; Due to smartconsole on windows we should all have powershell to work with.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 09 May 2016 12:44:48 GMT</pubDate>
    <dc:creator>Richard_Mason</dc:creator>
    <dc:date>2016-05-09T12:44:48Z</dc:date>
    <item>
      <title>Powershell Script to use with mgmt_cli</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Powershell-Script-to-use-with-mgmt-cli/m-p/2318#M72</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thought I would add this to show how to automate adding objects using a script on Windows machines.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. create hosts.csv with two columns headed host ipv4 and color eg&lt;/P&gt;&lt;P&gt;host,ipv4,color&lt;BR /&gt;node1,1.1.1.2,green&lt;BR /&gt;node2,2.2.2.3,yellow&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. Open powershell and cd to the Checkpoint mgmt_cli location&lt;/P&gt;&lt;P&gt;cd "C:\Program Files (x86)\CheckPoint\SmartConsole\R80\PROGRAM"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. Edit the below to point to the location of your csv file.&lt;BR /&gt;Also edit the management server ip, username and password.&amp;nbsp; These could be passed as $variables ??&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4. Paste all the below lines between ~#~#~&amp;nbsp; into a powershell.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;~#~#~#~#~#~&lt;/P&gt;&lt;P&gt;$hosts = Import-csv c:\path\to\hosts.csv&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;BR /&gt; #This will process the CSV row by row. Each row contains information to create ahost object with a name and ipv4-address&lt;BR /&gt;&amp;nbsp; &lt;BR /&gt; foreach ($node in $hosts)&lt;BR /&gt;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; $name = $node.host&lt;BR /&gt;&amp;nbsp;&amp;nbsp; $ipv4 = $node.ipv4&lt;BR /&gt;&amp;nbsp;&amp;nbsp; $color = $node.color&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; #create hosts from csv file, management server (-m) username (-u) and password (-p) are required fields.&lt;BR /&gt;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; .\mgmt_cli add host name $name ip-address $ipv4 color $color -m &amp;lt;MGMT_SERVER_HERE&amp;gt; -u &amp;lt;USER_HERE&amp;gt; -p &amp;lt;PASSWORD_HERE&amp;gt;&lt;BR /&gt; &lt;/P&gt;&lt;P&gt;&amp;nbsp; }&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;~#~#~#~#~#~&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This will publish each line after every pass.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 May 2016 09:53:41 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Powershell-Script-to-use-with-mgmt-cli/m-p/2318#M72</guid>
      <dc:creator>Richard_Mason</dc:creator>
      <dc:date>2016-05-09T09:53:41Z</dc:date>
    </item>
    <item>
      <title>Re: Powershell Script to use with mgmt_cli</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Powershell-Script-to-use-with-mgmt-cli/m-p/2319#M73</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Did you know:&amp;nbsp; mgmt_cli can accept csv files as inputs using the --batch option.&lt;/P&gt;&lt;P&gt;The first row should contain the argument names and the rows below it should hold the values for these parameters.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So an equivalent solution to the powershell script could look like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data.csv:&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;name&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;ipv4-address&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;color&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;host1&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;192.168.35.1&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;black&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;host2&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;192.168.35.2&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;red&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;host3&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;192.168.35.3&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;blue&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;mgmt_cli add host --batch data.csv -u &amp;lt;username&amp;gt; -p &amp;lt;password&amp;gt; -m &amp;lt;management server&amp;gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 May 2016 12:35:20 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Powershell-Script-to-use-with-mgmt-cli/m-p/2319#M73</guid>
      <dc:creator>Uri_Bialik</dc:creator>
      <dc:date>2016-05-09T12:35:20Z</dc:date>
    </item>
    <item>
      <title>Re: Powershell Script to use with mgmt_cli</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Powershell-Script-to-use-with-mgmt-cli/m-p/2320#M74</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No missed that, makes it even better and easier then &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://community.checkpoint.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I just wanted to show options for powershell as previous posts and scripts tend to be linux based.&amp;nbsp; Due to smartconsole on windows we should all have powershell to work with.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 May 2016 12:44:48 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Powershell-Script-to-use-with-mgmt-cli/m-p/2320#M74</guid>
      <dc:creator>Richard_Mason</dc:creator>
      <dc:date>2016-05-09T12:44:48Z</dc:date>
    </item>
    <item>
      <title>Re: Powershell Script to use with mgmt_cli</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Powershell-Script-to-use-with-mgmt-cli/m-p/2321#M75</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Love the API. Great forum. Thanks.&lt;/P&gt;&lt;P&gt;BUT:&lt;/P&gt;&lt;P&gt;API documentation found in misc. forum posts is bad.&lt;/P&gt;&lt;P&gt;API without proper online documentation diminishes the power of the API&lt;/P&gt;&lt;P&gt;See aws.amazon.com for what APIs with documentation should look like.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;dreez&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Jun 2016 11:38:35 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Powershell-Script-to-use-with-mgmt-cli/m-p/2321#M75</guid>
      <dc:creator />
      <dc:date>2016-06-24T11:38:35Z</dc:date>
    </item>
    <item>
      <title>Re: Powershell Script to use with mgmt_cli</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Powershell-Script-to-use-with-mgmt-cli/m-p/2322#M76</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;You can stream line the authentication elements of that script/command line with the "&lt;/SPAN&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;-s &amp;lt;session_id_file&amp;gt;&lt;/STRONG&gt;&lt;/SPAN&gt;" instead of having to provide "&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;-u &amp;lt;username&amp;gt; -p &amp;lt;password&amp;gt; -m &amp;lt;management server&amp;gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;"&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;, like this:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;mgmt_cli login user &amp;lt;smartconsole_administrator_name&amp;gt; -m &amp;lt;management server&amp;gt; &amp;gt; id.txt&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;...&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;mgmt_cli add host --batch data.csv -s id.txt&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;...&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;mgmt_cli publish -s id.txt&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;mgmt_cli logout -s id.txt&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;This will also then publish the changes and logout, closing that session, as it relates to the session id file.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;mgmt_cli defaults to using the management server at 127.0.0.1 or as defined by the environment variable "MGMT_CLI_MANAGEMENT".&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Jun 2016 14:54:00 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Powershell-Script-to-use-with-mgmt-cli/m-p/2322#M76</guid>
      <dc:creator>Eric_Beasley</dc:creator>
      <dc:date>2016-06-27T14:54:00Z</dc:date>
    </item>
    <item>
      <title>Re: Powershell Script to use with mgmt_cli</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Powershell-Script-to-use-with-mgmt-cli/m-p/2323#M77</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your feedback is probably best added here:&amp;nbsp; &lt;A href="https://community.checkpoint.com/thread/1191"&gt;Management API reference&lt;/A&gt; where Yonatan Philip is asking for input.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Jun 2016 18:35:15 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Powershell-Script-to-use-with-mgmt-cli/m-p/2323#M77</guid>
      <dc:creator>Eric_Beasley</dc:creator>
      <dc:date>2016-06-29T18:35:15Z</dc:date>
    </item>
    <item>
      <title>Re: Powershell Script to use with mgmt_cli</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Powershell-Script-to-use-with-mgmt-cli/m-p/2324#M78</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I tried to add all of the mgmt_cli commands into a file and execute but end up with following error:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I copy and paste the same commands into cli it works fine??&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Apr 2018 20:03:11 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Powershell-Script-to-use-with-mgmt-cli/m-p/2324#M78</guid>
      <dc:creator>Juan_Concepcion</dc:creator>
      <dc:date>2018-04-04T20:03:11Z</dc:date>
    </item>
    <item>
      <title>Re: Powershell Script to use with mgmt_cli</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Powershell-Script-to-use-with-mgmt-cli/m-p/2325#M79</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you please specify which commands and in which order?&lt;/P&gt;&lt;P&gt;Please be more specific and informative.&lt;/P&gt;&lt;P&gt;CLI window in SmartConsole works differently than mgmt_cli tool on the management server.&lt;/P&gt;&lt;P&gt;Robert.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 08 Apr 2018 07:29:50 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Powershell-Script-to-use-with-mgmt-cli/m-p/2325#M79</guid>
      <dc:creator>Robert_Decker</dc:creator>
      <dc:date>2018-04-08T07:29:50Z</dc:date>
    </item>
  </channel>
</rss>

