WhoIs PowerShell function will perform a domain name lookup and return information such as domain availability (creation and expiration date), domain ownership, name servers, etc..
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
PS C:\> whois power-shell.com Connecting to Web Services URL... Ok Gathering power-shell.com data... Whois Server Version 2.0 Domain names in the .com and .net domains can now be registered with many different competing registrars. Go to http://www.internic.net for detailed information. Domain Name: POWER-SHELL.COM Registrar: GODADDY.COM, LLC Whois Server: whois.godaddy.com Referral URL: http://registrar.godaddy.com Name Server: NS83.SUPERHOSTING.BG Name Server: NS84.SUPERHOSTING.BG Status: clientDeleteProhibited Status: clientRenewProhibited Status: clientTransferProhibited Status: clientUpdateProhibited Updated Date: 02-nov-2014 Creation Date: 17-oct-2014 Expiration Date: 17-oct-2015 >>> Last update of whois database: Sat, 20 Dec 2014 17:56:21 GMT |
Add this function to a module or save it as ps1 file and dot source it in your profile:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
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 { 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 (($Whois.getwhois(=$domain)).Split("<<<")[0]) } catch { Write-Host "Please enter valid domain name (e.g. microsoft.com)." -ForegroundColor Red} } |



I would love to use your function but, I have not been able to get the below code to work (took it down to bare minimums for troubleshooting).
$domain = “power-shell.com”
$whois = New-WebServiceProxy -uri “http://www.webservicex.net/whois.asmx?WSDL”
(($Whois.getwhois(=$domain)).Split(“<<<")[0])
I get the below errors.
Missing ')' in method call.
At C:\Temp\Domain.ps1:4 char:19
+ (($Whois.getwhois( <<<< =$domain)).Split("<<<")[0])
+ CategoryInfo : ParserError: (CloseParenToken:TokenId) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : MissingEndParenthesisInMethodCall
I've tried it with different domain names and quoted around the "=$domain" (like I've seen elsewhere) without improvement. Attempted it on Windows 7 and Windows 10.
Any help would be appreciated.
There is an error in the code at line 12 remove the = sign before $domain.
Should be:
(($Whois.getwhois($domain)).Split(“<<<")[0])
I wish I could get this too. It would be extremely useful. This script should be either fixed or removed since it doesn’t work.