Get input file, export CSV file without the rows from the input file

This post was originally published on this site

Hi LucD

 

I am trying to filter a VRNI CSV file and I need some help to exclude IP address which i have in an input.csv file

Once it excludes then i need to create a new CSV with only the excluded data

 

Here is my Input.CSV file

 

 

ipaddress
192,168,1,10
192,168,1,11
192,168,1,12
192,168,1,13
192,168,1,14

 

Here is my output.csv file

    

desip ALLOW Protocol SourceIP
192,168,1,10 ALLOW TCP 10,10,10,1
192,168,1,11 ALLOW TCP 10,10,10,2
192,168,1,12 ALLOW TCP 10,10,10,3
192,168,1,13 ALLOW TCP 10,10,10,4
192,168,1,14 ALLOW TCP 10,10,10,5
10.0.0.1 ALLOW UDP 10,10,10,6
10.25.102.61 ALLOW TCP 10,10,10,7
10.25.102.67 ALLOW TCP 10,10,10,8
10.25.102.73 ALLOW TCP 10,10,10,9
10.25.102.79 ALLOW TCP 10,10,10,10
10.25.102.85 ALLOW TCP 10,10,10,11
10.25.102.91 ALLOW TCP 10,10,10,12
10.25.102.97 ALLOW TCP 10,10,10,13
10.25.102.103 ALLOW TCP 10,10,10,14
10.25.102.109 ALLOW TCP 10,10,10,15
10.25.102.115 ALLOW TCP 10,10,10,16
10.25.102.121 ALLOW UDP 10,10,10,17
10.25.102.127 ALLOW UDP 10,10,10,18
10.25.102.133 ALLOW UDP 10,10,10,19

 

 

I need to read the Input CSV and if the IP address on the Input CSV matches the output.CSV then i need to exclude that line  and i need to export a new CSV file with the excluded CSV file

Because i dont need any ip address from the input file on the new CSV file because it garbage data

 

When i execute this code i get all the entries and its not excluding the data found from the input file

Can you help me with this please

 

Script

$inputfile=import-csv -Path “C:tempinput.csv”

$outputfile = import-csv -Path “C:TempVRNIOutputfile.CSV”

 

$outputfile |where {$inputfile.ipaddress -notin $_.desip}

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.