Excel file and fortinet automation

Simply make a batch file in windows and read from your excel file then convert the your datasheet to fortigate rules. In this code, I converted the excel file with 5 columns to the fortigate policy.

My Excel File:


My Batch file:

@echo off

>output-configuration-policy.txt (
echo:config firewall policy
set /a Counter=1

for /f “tokens=1-5 delims=,” %%A IN (C:\Users\rules.txt) DO (

echo edit !counter!
echo set name %%E
echo set srcintf vlan910-1135
echo set dstintf vlan1000-1135
echo set srcaddr %%A
echo set dstaddr %%C
echo set action accept
echo set service “HTTPS” “HTTP”
echo set schedule “always”
echo set logtraffic all
set /a counter=!Counter! + 1
echo next



I have added counter to count from 1 to number of your rules.


0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *