你能帮我对我的脚本做一个网站自动检查,将显示CNAME,A和AAAA记录,重定向域?还需要把每3个网站空行。
我尝试了这个示例脚本,但它没有显示所有CNAME
$NameList = @("w88live.com", "www.w88live.com", "m.w88live.com", "w88io.com", "www.w88io.com", "m.w88io.com")
$FinalResult = @()
foreach ($Name in ($NameList)) {
$tempObj = "" | Select-Object Name, PrimaryServer, IPAddress, Redirection
try {
$dnsRecord = Resolve-DnsName $Name -ErrorAction Stop -Type CNAME
$dnsRecord1 = Resolve-DnsName $Name -ErrorAction Stop -Type A_AAAA
$dnsRecord2 = invoke-webrequest -uri $Name -DisableKeepAlive -MaximumRedirection 0 -TimeoutSec 5 -ErrorAction Ignore -Method Head
$dnsRecord3 = Resolve-DnsName $Name -ErrorAction Stop -Type NS
#$dnsRecord2 = invoke-webrequest -UseBasicParsing $Name -DisableKeepAlive -MaximumRedirection 0 -TimeoutSec 10 -ErrorAction Stop
$tempObj.Redirection = ($dnsRecord2.Headers.Location -join "")
$tempObj.Name = $Name
$tempObj.PrimaryServer = ($dnsRecord.PrimaryServer -join " / ")
$tempObj.IPAddress = ($dnsRecord1.IPAddress -join ' / ')
}
catch {
$tempObj.Redirection = ($dnsRecord2.Headers.Location -join "")
$tempObj.Name = $Name
$tempObj.PrimaryServer = ($dnsRecord.PrimaryServer -join " / ")
$tempObj.IPAddress = ($dnsRecord1.IPAddress -join ' / ')
}
$FinalResult += $tempObj
}
return $FinalResult
我是新来的这个powershell,这就是为什么我迫切需要帮助。希望有好心的人可以帮助我。
谢谢!
1条答案
按热度按时间c8ib6hqw1#
这是一个开始