PowerShell – Query domain name WhoIs

Hi Guys,

I found, after couple of weeks looking for it, a cool API WebSite that provide an API to query WhoIs : webservicex.net.

Once I found out this site I started writing this little PowerShell function to help me serialize all my future actions with this little guy.

Here is the function I wrote for this purpose:
[ps]Function Get-WhoIsInfo {
Domain name WhoIs

Specifies the domain name

Get-WhoIsInfo -DomainName prudhomme.wtf

Author: Thomas Prud’homme
Blog: https://blog.prudhomme.wtf

Param (
Mandatory = $true,
HelpMessage = ‘Please enter domain name (e.g. prudhomme.wtf)’)
Begin {}
Process {
$WebUrl = ‘http://www.webservicex.net/whois.asmx/GetWhoIS?HostName={0}’ -f $DomainName

$WebData = Invoke-WebRequest -Uri $WebUrl -ErrorAction Stop
$WhoIsData = ([Xml]$WebData.Content).string.’#text’
New-Object -TypeName PSObject -Property @{
DomainName = $DomainName
WhoIsData = $WhoIsData
throw $_
End {}