You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何解决PowerShell中Get-ADUser cmdlet无法识别的问题

解决Get-ADUser cmdlet未识别及导入ActiveDirectory模块失败问题

问题场景

运行Get-ADUser时触发报错:

PS C:\> Get-ADUser
Get-ADUser : The term 'Get-ADUser' is not recognized as the name of a cmdlet, function, script file, or operable program.

尝试安装RSAT工具并导入模块后仍失败:

PS C:\> Add-WindowsCapability -Online -Name Rsat.ActiveDirectory.DS-LDS.Tools

Path          :
Online        : True
RestartNeeded : False

PS C:\> Import-Module -Name ActiveDirectory
Import-Module : The specified module 'ActiveDirectory' was not loaded because no valid module file was found in any module directory.

PS C:\> Get-ADUser
Get-ADUser : The term 'Get-ADUser' is not recognized as the name of a cmdlet, function, script file, or operable program.

已有一台机器可正常运行该cmdlet,需在其他机器启用此功能。

解决步骤

1. 确认RSAT组件安装命令的正确性

针对Windows 10 1809+/Windows 11/Windows Server 2019+版本,需使用完整的Capability名称执行安装:

Add-WindowsCapability -Online -Name Rsat.ActiveDirectory.DS-LDS.Tools~~~~0.0.1.0

若为Windows 10 1809以下版本,需通过控制面板-程序-启用或关闭Windows功能,在「远程服务器管理工具」下勾选「Active Directory域服务和轻量目录服务工具」完成安装。

2. 验证RSAT组件是否真的安装成功

执行命令检查组件状态:

Get-WindowsCapability -Online | Where-Object Name -like "*ActiveDirectory*"

确认目标组件状态为Installed,若显示NotPresent,重新运行安装命令,必要时重启机器后再次检查。

3. 手动指定模块路径导入

若模块已安装但无法通过名称导入,直接指定模块文件路径执行导入:

Import-Module "C:\Windows\System32\WindowsPowerShell\v1.0\Modules\ActiveDirectory\ActiveDirectory.psd1"

4. 检查PowerShell运行环境

  • 确保使用64位PowerShell(AD模块仅支持64位),若当前为32位环境(路径含SysWOW64),切换到64位版本重试。
  • 以管理员身份运行PowerShell,避免权限不足导致模块加载失败。

5. 对比正常机器的模块配置

在可正常运行的机器上导出模块信息:

Get-Module -Name ActiveDirectory -ListAvailable | Select-Object Name, Path, Version | Format-List

将结果与问题机器对比,若模块文件缺失,可从正常机器复制C:\Windows\System32\WindowsPowerShell\v1.0\Modules\ActiveDirectory文件夹到对应路径(需确保系统版本一致)。

内容的提问来源于stack exchange,提问作者xpt

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.16 22:44:58