Created
November 2, 2017 23:52
-
-
Save DarthJahus/b4eeef67b77da99d500eab90dd4d87c0 to your computer and use it in GitHub Desktop.
Whois command for PowerShell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
Domain name WhoIs | |
.DESCRIPTION | |
Performs a domain name lookup and returns information such as | |
domain availability (creation and expiration date), | |
domain ownership, name servers, etc. | |
.PARAMETER domain | |
Specifies the domain name (enter the domain name without http:// and www (e.g. power-shell.com)) | |
.EXAMPLE | |
WhoIs -domain power-shell.com | |
whois power-shell.com | |
.NOTES | |
File Name: whois.ps1 | |
Author: Nikolay Petkov | |
Blog: http://power-shell.com | |
Last Edit: 12/20/2014 | |
Made by: KornKolio (https://gallery.technet.microsoft.com/WHOIS-PowerShell-Function-ed69fde6) | |
Add it to your $profile, line: . PATH\whois.ps1 | |
Or dot-source it: . PATH\whois.ps1 | |
You may need to Set-ExecutionPolicy | |
.LINK | |
http://power-shell.com | |
#> | |
Function WhoIs { | |
param ( | |
[ | |
Parameter( | |
Mandatory=$True, | |
HelpMessage='Please enter domain name (e.g. microsoft.com)' | |
) | |
] | |
[string]$domain | |
) | |
Write-Host "Connecting to Web Services URL..." -ForegroundColor Green | |
try { | |
# Retrieve the data from web service WSDL | |
If ($whois = New-WebServiceProxy -uri "http://www.webservicex.net/whois.asmx?WSDL") { | |
Write-Host "Ok" -ForegroundColor Green | |
} | |
else { | |
Write-Host "Error" -ForegroundColor Red | |
} | |
Write-Host "Gathering $domain data..." -ForegroundColor Green | |
# Return the data | |
( | |
($whois.getwhois("=$domain")).Split("<<<")[0] | |
) | |
} | |
catch { | |
Write-Host "Please enter valid domain name (e.g. microsoft.com)." -ForegroundColor Red | |
} | |
} | |
# end function WhoIs |
I'm getting the same error message. seems a few different scripts out there point to the same webproxy but they fail:
New-WebServiceProxy : The underlying connection was closed: The connection was closed unexpectedly.
At C:\scripts\whois3.ps1:43 char:16
- ... f ($whois = New-WebServiceProxy -uri "http://www.webservicex.net/whoi ...
-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- CategoryInfo : ObjectNotFound: (http://www.webs...whois.asmx?WSDL:Uri) [New-WebServiceProxy], WebException
- FullyQualifiedErrorId : WebException,Microsoft.PowerShell.Commands.NewWebServiceProxy
Ideas?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Getting error on creating web service reference New-WebServiceProxy : The HTML document does not contain Web service discovery information