术语'Get-ADUser'不被认可为一个cmdlet的名称
我使用下面的查询来列出windows 2008服务器中的用户,但是失败了,得到的错误如下。
$server='client-pc-1';$pwd= convertto-securestring 'password$' -asplaintext -
force;$cred=new-object -typename System.Management.Automation.PSCredential -argumentlist 'Administrator',$pwd; invoke-command -computername $server -credential
$cred -scriptblock {Get-ADUser -Filter (enabled -ne $true)}
异常情况如下......谁能帮我解决这个问题?
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.
+ CategoryInfo : ObjectNotFound: (Get-ADUser:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
86
3
如果有ActiveDirectory模块存在,则添加
在你的代码之前。
要检查是否存在,请尝试。
ActiveDirectory模块在windows server 2008 R2中是默认存在的,请用这种方式安装它。
为了让它工作,你需要在域中至少有一个DC是windows 2008 R2,并在其上安装活动目录网络服务(ADWS)。
对于Windows Server 2008,请阅读这里如何安装它。
请查看这里,了解如何在默认情况下添加activedirectory模块。这可以在任何机器上完成,然后它将允许你访问你的活动目录"域控制" 服务器。
编辑
为了防止链接过期的问题(过去我曾发现MSDN博客无故消失),实质上对于Windows 7来说,你需要下载并安装[远程服务器管理工具(KB958830)](http://www.microsoft.com/en-us/download/details.aspx?id=7887)。安装后做以下步骤。
Windows服务器版本应该已经OK了,但如果没有,你需要下载并安装活动目录管理网关服务。如果这些链接中的任何一个应该停止工作,你应该仍然能够搜索KB文章或下载名称并找到它们。
如果你没有看到活动目录,这是因为你没有安装AD LS用户和计算机功能。 转到管理 - 添加角色和功能。 在添加角色和功能向导中,在功能标签上,选择远程服务器管理工具,选择 - 角色管理工具 - 选择AD DS和DF LDS工具。
之后,你可以看到PS活动目录包。