我正在尝试更新位于(我相信)服务器上以下路径的 DNS 记录:
ServerName -> Forward Lookup Zones -> domain.com -> test
其中 DNS 记录称为 test
,类型为 Host(A)
。
我从 here 下载了 DNSShell
模块并尝试使用以下命令更改 DNS 记录(包含 IP 地址)的“数据”列:
Set-DNSRecord -Identity "test.domain.com"
但是我得到了这个错误:
Cannot validate argument on parameter 'Identity'. The argument "test.domain.com" does not match the "^\\.\root\MicrosoftDNS:MicrosoftDNS_" pattern. Supply an argument that matches "^\\.\root\MicrosoftDNS:MicrosoftDNS_" and try the command again.
所以我更新了 Identity
参数如下:
Set-DNSRecord -Identity "\\Servername\root\MicrosoftDNS:MicrosoftDNS_"
但现在我看到了:
Set-DNSRecord : Specified argument was out of the range of the valid values. Parameter name: Path
当我尝试添加 -Path
时,它说没有这样的参数!有谁知道我需要在哪里添加 DNS 的 test.domain.com
部分来告诉命令要更新哪条记录?该模块的这一部分的文档不完整,我似乎找不到任何替代方案。
我可以调用 Get-DNSRecord
并查看我需要更新的记录,但是任何 Set
的尝试都会被阻止,因为我不知道这些路径是如何构建的。
非常感谢任何帮助。
最佳答案
您也可以为 Microsoft 的 DNS 服务器使用默认的 PowerShell 模块,示例如下所示:
Add-DnsServerResourceRecordA -Name "recordname" -IPv4Address "192.168.0.0" -ZoneName "domain.com" -AllowUpdateAny -AgeRecord
如果您需要在此之前删除,像这样的东西应该可以工作:
Remove-DnsServerResourceRecord -ZoneName "domain.com" -Name "recordname" -RRType "A" -Force
关于powershell - 如何以编程方式更新 DNS 记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36768539/