Snippet of PowerShell to extract IP addresses from a file

$Input_File = ‘C:\Temp\Input_File.txt’

$Output_File = ‘C:\Temp\Extracted_IP_Addresses.txt’

$RegEx = ‘\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b’

Select-String -Path $Input_File -Pattern $RegEx -AllMatches | % { $_.Matches } | % { $_.Value } > $Output_File

Leave a Reply

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