如何在 Office 365/Azure 中使用 Powershell 添加/更新自定义 DNS A 记录?所以我可以在 ISP 更改 IP 地址时更新它

How to add/ update custom DNS A Records using Powershell in Office 365/ Azure? So I can update IP address when ISP changes it

现在我正在使用 Microsoft Office 365 管理中心来管理域和子域。但我想看看我是否可以使用 powershell 将 DNS A 记录添加/更新到新的 IP 地址。这将有助于在我的 ISP 分配 IP 时更新到新 IP,然后我可以使用 powershell 更新所有“A 记录”以反映新 IP 地址。任何人都知道这是否可以使用 powershell?提前谢谢你。

有关如何使用 UI 执行此操作的参考: https://docs.microsoft.com/en-us/microsoft-365/admin/dns/update-dns-records-to-retain-current-hosting-provider?view=o365-worldwide

据我测试,使用 PowerShell 不支持 setting/updatting A records 到 O365,但支持 DnsMXRecordDnsTxtRecord。参考:Command definition.

这里是 Add a Domain to Office 365 and Azure using PowerShell 的例子。

它对我有效: