Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Powershell script to check IPv4 and IPv6 pattern recursively in the entire drive/code

$
0
0

I want to extract IPv4 and IPv6 pattern wherever used in the bunch of files/codes. I am using the below script but that fetches me only IPv4.

$regex ="\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b"
cd "D:\"
$excluded = @("*.pdf", "*.jpg", "*.jpeg", "*.dll", "*.exe", "*.gif", "*.png", "*.css", "*.vbproj", "*.vspscc", "*.rpt", "*.pdb", "*.zip", "*.rar", "*.flv", "*.cache", "*.dat", "*.bin", "*.sln", "*.wmv", "*.mpg", "*.mpeg", "*.tif", "*.ppt", "*.pptx" ,"*.pps", "*.pub", "*.swf", "*.msi")
Get-ChildItem -Recurse -exclude $excluded | 
Select-String -Pattern $regex | Select-Object path,line,linenumber,filename | Export-Csv -Path "D:\result.csv" -notype
How can I fetch all the possible patterns of IPv6 addresses along with IPv4, recursively. I am using Powershell 2.0


Viewing all articles
Browse latest Browse all 6937

Trending Articles