我试图复制现有的用户,用新的名称等,一个新的用户复制的广告用户..我如何通过PowerShell的
$root = New-Object System.DirectoryServices.DirectorySearcher
$root.SearchRoot = "LDAP://dc=organization,dc=net"
$root.Filter = "(&(objectClass=user)(samaccountname=TestUser1))"
$result = $root.FindOne()
$test = $result.GetDirectoryEntry()
$newparent = New-Object System.DirectoryServices.DirectoryEntry($test.Parent)
$test.CopyTo($newparent,"TestUser2")
每当我运行上面的代码,我不断收到:
ERROR: Exception calling "CopyTo" with "2" argument(s): "Not implemented
ERROR: "
TestDir.ps1 (22): ERROR: At Line: 22 char: 13
ERROR: + $test.CopyTo <<<< ($newparent,"TestUser2")
ERROR: + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
ERROR: + FullyQualifiedErrorId : DotNetMethodException
ERROR:
有谁知道这个问题可能是什么?我知道我想要达到的ActiveDirectory模块和任务存在..但我没有访问这些等于是我从头开始编写这个..
感谢
正如我在原来的帖子中写道,我没有访问ActiveDirectory的模块,所以我在寻找如何使用的DirectoryServices做到这一点。 thx – halv 2014-11-01 13:37:57
对不起。我会研究它 – 2014-11-01 15:10:04