Strony

piątek, 5 stycznia 2024

PowerShell: Search-IP. Function that searches clipboard, files for IP Addresses, deduplicate and sort them

 Background

Very often I have need for fast search, deduplicate and sort IP addresses in data from different sources: pdf reports, articles, logs.
This should include addresses which are written in safe format, with dots in brackets, like: 
  • 192.168.0[.]1 
  • 192.168.0(.)1
This is no problem when you have log with ~10 addresses or so, but if you have log file with ~50k - ~100k this could be a problem.

Solution

The function named Search-IP (link do Github repository) which was written in PowerShell. 

How it works

There is diagram below which showing how function works divided into 3 steps:
  • Input,
  • Working,
  • Output
Logical diagram of the function's operation
Logical diagram of the function's operation