-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTest-Domain.ps1
41 lines (32 loc) · 1.04 KB
/
Test-Domain.ps1
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
function Test-Domain
{
Param(
[parameter(Mandatory=$true)]
[String]$Domains
)
$uri = "https://api.openprovider.eu/v1beta/domains/check"
$DomlistArray = @()
$bearcreds = Get-BearereCreds
$IdnScript = [pscustomobject]@{
idn_scrypt = "cyrl"}
Foreach ($Domain in $Domains)
{
$TLD = $Domain.Substring($Domain.IndexOf(".") + 1)
$DomName = ($domain.Split("."))[0]
$Domlist = [pscustomobject]@{
extension = $TLD
name = $DomName}
$DomListArray = $DomListArray + $DomList
}
$DomBody = [pscustomobject]@{
additional_data = $IdnScript
application_mode = "preregistration"
domains = $DomListArray
with_price = $true
with_whois = $true } # returns no result. Seems to have been depreciated.
$DomBodyJson = $DomBody | ConvertTo-Json
$Bearer = Get-BearereCreds
$Domheader = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$Domheader.Add("Authorization","Bearer " + $bearcreds.token)
$Result = Invoke-RestMethod -Method Post -Uri $uri -Headers $Domheader -body $DomBodyJson -ContentType 'application/json'
return $Result.data.results