stash/Get-Whois.ps1

function Get-Whois {
  [CmdletBinding()]
  param(
    [Parameter(Mandatory, ValueFromPipeline)]
    [ValidateNotNullOrEmpty()]
    [String]$Domain
  )

  process {
    $Headers = @{
      "Accept" = 'application/json, text/plain, */*'
      "Origin" = 'https://www.nic.ru'
      "Sec-Fetch-Site" = 'same-origin'
      "Sec-Fetch-Mode" = 'cors'
      "Referer" = "https://www.nic.ru/whois/?searchWord=$Domain"
      "Accept-Encoding" = 'gzip, deflate, br'
    }

    $params = @{
      Uri = 'https://www.nic.ru/app/v1/get/whois'
      Method = 'POST'
      Headers = $Headers
      ContentType = 'application/json;charset=UTF-8'
      Body = "{`"searchWord`":`"$Domain`"}"
    }

    if (($res = Invoke-WebRequest @params).StatusCode -ne 200) {
      throw [InvalidOperationException]::new($res.StatusDescription)
    }

    ($res.Content | ConvertFrom-Json).body.list.ForEach{
      "`e[35;1mRegistry`e[33;0m: $($_.registry)"
      .({
        foreach ($item in $_.formatted) {
          "`e[36;1m$($item.name)`e[33;0m $($item.value -replace '<[^>]*>')"
        }
        ''
      }, {$_.html -replace '<[^>]*>'})[!!$_.html]
    }
  }
}