Extract IP Addresses from File with PowerShell

$input_path = ‘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_path -Pattern $regex -AllMatches | % { $_.Matches } | % { $_.Value } > $output_file

Leave a Reply

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