
well you know how to view files with Powershell Command Get-Content, but lets say
you need to find some text on your file ,or find only IP’s ..
good example can be learned from examine IIS Log File, which is a big content file ,or some xml file you need to handle.
here’s a script will help you find only IP’s on the file you’ll select –
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
#This script is scanning any file name for IP Addresses function Scan4IPs { <# .Synopsys Scan any file for IP Addresses ,then try to resolve name. .Description if you having a large txt/xml/config file and you would like to know which IP Addresses exist on this file, just ran this script and it'll show you the IP Addresses was found on chosen file. .Example C:\ScanIPs d:\Logs\FolderName\FileName.txt-xml-config-html #> param($path) $IPRegex = "\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}" $ipadds = @() $ipadd = Get-Content $path | Select-String -Pattern $IPRegex -AllMatches | % { $_.Matches } | % {$_.value} $ipadds += $ipadd $ipadds } |
Now ,after you were able to find IP’s on the file won’t you be glad to know who’s ip’s belongs to ?
you can check it out with ResolveIPtoName Script function.
(Visited 3,631 times, 1 visits today)