title: PowerShell's input file changes and does not run. firewall
body: <p>I didn't make it. <a href="https://lifestream.kr/90" rel="nofollow noreferrer">https://lifestream.kr/90</a> (Original address)</p>
  <p>I want to block a specific country ip.</p>
  <p>Except for my country. Also, I want to block ip except for router ip Google dns.</p>
  <p>China, Russia and North Korea. These three countries.</p>
  <p>The old one works well.</p>
  <p>But it doesn't work after swapping files.</p>
  <p><code>GeoIPCountryWhois.csv</code>=The file is old. Updates are no longer supported. a chargeable conversion</p>
  <p>.</p>
  <p><code>GeoIPCountryWhois.csv</code>=original file(old) ,  <code>IP2LOCATION-LITE-DB1.CSV</code>=A new file I want to put in.</p>
  <p><a href="https://dev.maxmind.com/geoip/docs/databases/city-and-country?lang=en#csv-databases" rel="nofollow noreferrer">https://dev.maxmind.com/geoip/docs/databases/city-and-country?lang=en#csv-databases</a>
  It became a paid service.=<code>GeoIPCountryWhois.csv</code></p>
  <p><a href="https://download.ip2location.com/lite/" rel="nofollow noreferrer">https://download.ip2location.com/lite/</a> This is a free service.=<code>IP2LOCATION-LITE-DB1.CSV</code></p>
  <p><code>GeoIPCountryWhois.csv</code>=The file works fine.</p>
  <p><code>IP2LOCATION-LITE-DB1.CSV</code>=But... this file doesn't work.</p>
  <p>.</p>
  <p>The files are different.</p>
  <p>original file <code>GeoIPCountryWhois.csv</code></p>
  <pre><code>&quot;1.0.0.0&quot;,&quot;1.0.0.255&quot;,&quot;16777216&quot;,&quot;16777471&quot;,&quot;AU&quot;,&quot;Australia&quot;
  &quot;1.0.1.0&quot;,&quot;1.0.3.255&quot;,&quot;16777472&quot;,&quot;16778239&quot;,&quot;CN&quot;,&quot;China&quot;
  &quot;1.0.4.0&quot;,&quot;1.0.7.255&quot;,&quot;16778240&quot;,&quot;16779263&quot;,&quot;AU&quot;,&quot;Australia&quot;
  &quot;1.0.8.0&quot;,&quot;1.0.15.255&quot;,&quot;16779264&quot;,&quot;16781311&quot;,&quot;CN&quot;,&quot;China&quot;
  </code></pre>
  <p>.</p>
  <p>Free version file <code>IP2LOCATION-LITE-DB1.CSV</code></p>
  <pre><code>&quot;0&quot;,&quot;16777215&quot;,&quot;-&quot;,&quot;-&quot;
  &quot;16777216&quot;,&quot;16777471&quot;,&quot;US&quot;,&quot;United States of America&quot;
  &quot;16777472&quot;,&quot;16778239&quot;,&quot;CN&quot;,&quot;China&quot;
  &quot;16778240&quot;,&quot;16779263&quot;,&quot;AU&quot;,&quot;Australia&quot;
  &quot;16779264&quot;,&quot;16781311&quot;,&quot;CN&quot;,&quot;China&quot;
  &quot;16781312&quot;,&quot;16785407&quot;,&quot;JP&quot;,&quot;Japan&quot;
  </code></pre>
  <p>So I can't apply the new file</p>
  <p><code>.\test.ps1</code></p>
  <pre><code>#############Config#################
  $countryCode=&quot;CN&quot;, &quot;RU&quot;, &quot;KP&quot; #차단할 나라의 CountryCode
  #$geoIPcvsPath=&quot;d:\IP2LOCATION-LITE-DB1.CSV&quot;
  $geoIPcvsPath=&quot;\IP2LOCATION-LITE-DB1.CSV&quot;
  $ruleName=&quot;blockCountry&quot;
  #############Config#################
   
   
  $geoData=Import-Csv $geoIPcvsPath -header sIP, eIP, start, end, cc, cn |  where-object {$_.cc –in $countryCode}
  $geoDataTotal=$geoData.Count
  $remoteIP=&quot;&quot;
   
   
  ######  룰이 있는 지 체크 ########
  function ruleExistsChk ($ruleName)
  {
      $fw=New-object -comObject HNetCfg.FwPolicy2; # http://blogs.technet.com/b/jamesone/archive/2009/02/18/how-to-manage-the-windows-firewall-settings-with-powershell.aspx
      $RuleCHK=$fw.rules | where-object {$_.name –eq $ruleName}
      if(!$RuleCHK){
      #$deny_rule_name + &quot; 룰이 생성되어 있지 않습니다.&quot;; exit;
      netsh advfirewall firewall add rule name=&quot;$ruleName&quot; localip=any dir=in action=block profile=&quot;any&quot; interfacetype=&quot;any&quot;
      }
  }
  ######  룰이 있는 지 체크 ########
   
   
  $count=1
  foreach ($geoIP in $geoData)
  {
      #$remoteIP+=@($geoIP.sIP+&quot;-&quot;+$geoIP.eIP+&quot;,&quot;) #배열로 저장.
       $remoteIP+=$geoIP.sIP+&quot;-&quot;+$geoIP.eIP+&quot;,&quot;
        
       #remoteAddr가 한개의 룰에 약 300개 이상이면 등록이 안됨. 안전하게 200으로 설정.
      if(($count%200) -eq 0)
      {
          $makeRuleName=$ruleName+$countryCode+$count
          ruleExistsChk($makeRuleName)
          netsh advfirewall firewall set rule name=$makeRuleName new remoteip=&quot;$remoteIP&quot;
          $remoteIP=&quot;&quot;
      }elseif($geoDataTotal -eq $count){
          $makeRuleName=$ruleName+$countryCode+$count
          ruleExistsChk($makeRuleName)
          netsh advfirewall firewall set rule name=$makeRuleName new remoteip=&quot;$remoteIP&quot;
          $remoteIP=&quot;&quot;
      }
   
       $count++
   
  }
  </code></pre>
  <p>If you run it, nothing happens.</p>
  <p>The command I ordered to register is not generated, but only the computer cursor appears.</p>
  <p><code>findstr /blv &quot;# 0.0.0. 192.168.0.0/16 224.0.0.0/16 172.30. 192.168. 224.0. 168.126. 210.220. 219.250. 61.41. 1.214. 164.124. 203.248. 180.182. 94.140. 208.67. 1.1. 1.0. 8.8. 9.9. 149.112. 194.242. 185.222. 45.11. 10.0. 172.162&quot;</code> I'd like to exclude some ip.</p>
  <p><code>https://mirror.dk.team.blue/firehol/ip2location_country/ip2location_country_kr.netset</code>
  And I want to exclude Korean IP from the above ip. Because I am Korean in Seoul.. Because I can't use the internet if similar ip Korea is blocked.</p>
  <p>There are three questions.</p>
  <p>Thank you.</p>