我試圖複製現有的用戶,用新的名稱等,一個新的用戶複製的廣告用戶..我如何通過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