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

Writing a whois for multipel ips

$
0
0

 

Hi I have started to write some small thingy to run whois with some proxy parameters.

Try to use the webservicex.net and the whois function.

param([String]$domain)
if ($domain -eq "") { $domain = Read-Host "Please Enter Domain" }
if ($domain -eq "") { Write-Host "No domain was entered, quitting.." }
else {
 
$wc = New-Object System.Net.WebClient
$wc.Proxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
$wc = New-WebServiceProxy 'http://www.webservicex.net/whois.asmx?WSDL'
$wc.GetWhoIs($domain)
}

and that work, but when i got to do this on mutlipel ips from a source file with ip.

$servers = Get-Content C:\Scripts\hostlist.txt
 
foreach ($_ in $servers) {
 
$wc = New-Object System.Net.WebClient
$wc.Proxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
$wc = New-WebServiceProxy 'http://www.webservicex.net/whois.asmx?WSDL'
$wc.GetWhoIs($_) | Out-File -FilePath C:\Scripts\output.txt -Append -Force
}

it does not work, any ideas of the script or just a other great function to use.

 

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles