获取域名到期

时间:2019-06-11 20:26:24

标签: powershell

我正在寻找一种方法来获取我们拥有的域名列表,并在到期时通过电子邮件发送报告。

我找到了这个脚本,但是找不到为什么它不起作用。说它缺少右括号,但我没有看到它。

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
    }
}
New-WebServiceProxy : The request failed with HTTP status 404: Not Found.
At line:9 char:14
+ ... f ($whois = New-WebServiceProxy -Uri "webservicex.net/whoi ...
+       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     + CategoryInfo          : ObjectNotFound: (webs...whois.asmx?WSDL:Uri) [New-WebServiceProxy], WebException
     + FullyQualifiedErrorId : WebException,Microsoft.PowerShell.Commands.NewWebServiceProxy

0 个答案:

没有答案