【发布时间】:2014-11-01 11:03:20
【问题描述】:
我正在尝试将现有用户复制到具有新名称的新用户等。
$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 模块和 Quest 中。但我无权访问这些,因此我必须从头开始编写。
谢谢
【问题讨论】:
标签: powershell active-directory directoryservices