繁体   English   中英

使用 Get-ADUsers 在 powershell 中查找信息不起作用,无法识别术语

[英]using Get-ADUsers to find info in powershell not working, term not recognized

我正在尝试从我的 AD 用户那里检索一些信息,在 PowerShell 上使用以下命令:

get-aduser -identity username -Properties * | select DisplayName, City, State 

但它给了我这个错误:

get-aduser : The term 'get-aduser' 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-aduser -identity username -Properties * | select DisplayName, Cit ...
+ ~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (get-aduser:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

我还尝试添加此导入:

Import-Module ActiveDirectory

但是我却得到了另一个错误:

Import-Module : The specified module 'ActiveDirectory' was not loaded because no valid module file was found in any module directory.
At line:1 char:1
+ Import-Module ActiveDirectory
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (ActiveDirectory:String) [Import-Module], FileNotFoundException
    + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand

我究竟做错了什么?

您需要安装RSAT 工具才能使用ActiveDirectory模块。

如果您安装了Windows 10 October 2018 Update或更高版本,则可以将 RSAT 工具安装为 Windows 功能:

注意:下面的示例不使用直接名称,因为名称末尾有版本后缀。

Get-WindowsCapability -Online | Where-Object { $_.Name -like "Rsat.ActiveDirectory.DS-LDS.Tools*" } | Add-WindowsCapability -Online

否则,您可以从我之前提供的链接安装 RSAT 工具。 那里包含有关如何手动安装仍受支持的 Windows 版本的说明。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM