powershell - 如何通过 powershell 解析最新的 DNS CName 结果
问题描述
我正在尝试使用以下 powershell 脚本解析最新的 DNS CName。但是由于 DNS 服务器缓存,我得到的缓存主机名不是最新的 CName。有没有办法避免这种情况并获得最新的结果?(如在 digwebinterface.com 中)
之后我调用第三方 DNS 管理 API,它将修改或创建 DNS CName 映射。为此,我需要最新的 dns 数据。
#resolve the dns host name
$resolvedCName = Resolve-DnsName -Name $vanityHostName -DnsOnly -Type CNAME |
Select-Object -First 1 -Property Name,NameHost
write-host $resolvedCName.NameHost
解决方案
这不是 PowerShell 问题或错误。它是一个环境条件。
为什么你不只是清除缓存作为你正在做的事情的一部分?
您是说 DnsClientCache cmdlet 或 Ipconfig -FlushDNS 没有为您提供您所追求的东西吗?
Clear-DnsClientCache cmdlet删除 DNS 客户端缓存的所有内容。运行此 cmdlet 等效于运行 ipconfig /flushdns。
Get-Command -Name Clear-DnsClientCache | Format-Table -AutoSize
<#
CommandType Name Version Source
----------- ---- ------- ------
Function Clear-DnsClientCache 1.0.0.0 DnsClient
#>
# get function / cmdlet details
Get-Command -Name Clear-DnsClientCache -Syntax
(Get-Command -Name Clear-DnsClientCache).Parameters.Keys
Get-help -Name Clear-DnsClientCache -Full
Get-help -Name Clear-DnsClientCache -Online
Get-help -Name Clear-DnsClientCache -Examples
ipconfig /?
<#
USAGE:
ipconfig [/allcompartments] [/? | /all |
/renew [adapter] | /release [adapter] |
/renew6 [adapter] | /release6 [adapter] |
/flushdns | /displaydns | /registerdns |
/showclassid adapter |
/setclassid adapter [classid] |
/showclassid6 adapter |
/setclassid6 adapter [classid] ]
where
adapter Connection name
(wildcard characters * and ? allowed, see examples)
Options:
...
/flushdns Purges the DNS Resolver cache.
/registerdns Refreshes all DHCP leases and re-registers DNS names
…
#>
推荐阅读
- sql-server - Docker Deskop 2.3.0.2 for Windows - 主机卷停止工作
- angular - 从下拉列表中的 mat-table 列名称及其在 Angular 7/8/9 中的文本输入中的值过滤
- c - 在哈希表中找到最大值,然后打印具有该值的所有变量(在 C 中)
- python - 如何绘制具有散景和正确方向角的椭圆?
- reactjs - 测试 --coverage 抛出“渲染没有返回任何内容。” 错误
- javascript - 如何从价格中检测和捕获更改(更新)的价格?
- c# - 在 XAML C# WPF 中设置 DataContext
- c# - 从类模式中选择一个字段
- c# - 如何在 Unity 中输入瓦片时将 NavMeshAgents 排队(基于到瓦片的路径距离)?
- php - ffmpeg 降低照片质量