Skip to content

Instantly share code, notes, and snippets.

@martin9700
Created March 6, 2014 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save martin9700/9390464 to your computer and use it in GitHub Desktop.
Save martin9700/9390464 to your computer and use it in GitHub Desktop.
#requires -Version 4.0
$Path = "c:\test"
$Data = ForEach ($Domain in (Get-Content $Path\domains.txt))
{ $Web = Invoke-RestMethod -Uri "http://www.restfulwhois.com/v1/$Domain" -Headers @{"accept"="application/json"}
$TimeSpan = New-TimeSpan -Start (Get-Date) -End ((Get-Date "1/1/1970").AddMilliseconds($Web.expiry))
$DaysLeft = "$($TimeSpan.Days) Days, $($TimeSpan.Hours) Hours, $($TimeSpan.Minutes) Minutes"
[PSCustomObject]@{
Domain = $Domain
Status = $Web.Status -join ", "
Created = (Get-Date "1/1/1970").AddMilliseconds($Web.registered)
Updated = (Get-Date "1/1/1970").AddMilliseconds($Web.updated)
Expires = (Get-Date "1/1/1970").AddMilliseconds($Web.expiry)
DaysLeft = $DaysLeft
Registrar = $Web.Registrar.Name
ns = $Web.ns.ipv4 -join ", "
}
}
$Header = @"
<style>
TABLE {border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}
TH {border-width: 1px;padding: 3px;border-style: solid;border-color: black;background-color: #6495ED;}
TD {border-width: 1px;padding: 3px;border-style: solid;border-color: black;}
</style>
"@
$Data | ConvertTo-Html -Head $Header -PreContent "<h2>Domain Information</h2>" -PostContent "<h6>Run on: $(Get-Date)</h6>" | Out-File $Path\DomainInfo.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment