如何让 DNS 服务器 cmdlet 在 Windows 10 中的 PowerShell 上运行?

如何让 DNS 服务器 cmdlet 在 Windows 10 中的 PowerShell 上运行?

当我尝试使用 DNS cmdlet 时,出现“无法识别”错误...

PS C:\Users\josh\Documents\GitHub\GoDaddy> get-dnsserverresourcerecord
get-dnsserverresourcerecord : The term 'get-dnsserverresourcerecord' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that 
the path is correct and try again.
At line:1 char:1
+ get-dnsserverresourcerecord
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (get-dnsserverresourcerecord:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

如何将这些功能导入Windows 10?

答案1

如果您使用的是非服务器操作系统(如 Windows 10),则可以添加一堆远程服务器管理工​​具(RSAT)作为可选功能。

从 Windows 10 2018 年 10 月更新开始,RSAT 就作为一组“按需功能”包含在 Windows 10 中。转到“设置”中的“管理可选功能”,然后单击“添加功能”以查看可用的 RSAT 工具列表。选择并安装RSAT:DNS 服务器工具特征。

仅当您使用的是旧版本的 Windows 时:请参阅此处的说明并安装软件包https://www.microsoft.com/en-us/download/details.aspx?id=45520

*-dnsserver*在本地计算机上安装该包后,cmdlet 将立即在 PowerShell 中开始运行。

答案2

您还可以使用隐式远程处理来临时导入远程命令,而无需安装 RSAT:

$session = new-pssession -ComputerName server
Invoke-Command -command {Import-Module dnsserver} -Session $session
Import-PSSession -Session $session -Module dnsserver -Prefix RemoteDNS

前缀将标记导入的命令,以便您可以跟踪远程命令。导入命令后,您可以使用名词前的前缀来运行它们。

例如:

Get-RemoteDNSdnsserverresourcerecord代替get-dnsserverresourcerecord

但是前缀是可选的。

答案3

根据撰写本文的时间(Windows 10 Pro - 20H2),您可以使用 Windows 10 Pro 或 Enterprise 在以下位置找到 RSAT(远程服务器管理工​​具):
设置 -> 应用程序 -> 应用程序和功能 -> 可选功能 -> 添加功能
在搜索字段中输入“RSAT”以选择您需要的模块

答案4

2022 列出 Win10 上安装的 Windows 功能 (Powershell)

Get-WindowsOptionalFeature -Online | Where Name -Match "RSAT.*" | Format-Table -Autosize

安装 RSAT.DNS.TOOLS

Add-WindowsCapability -Online -Name Rsat.Dns.Tools

相关内容