2008-09-16 93 views
7

如何使用Powershell將活動目錄組移動到另一個組織單位?使用Powershell將Active Directory組移動到另一個OU

即。

我想團 「IT部」 從移動:

(CN=IT Department, OU=Technology Department, OU=Departments,DC=Company,DC=ca) 

到:

(CN=IT Department, OU=Temporarily Moved Groups, DC=Company,DC=ca) 

回答

6

你的腳本非常接近正確(我非常感謝你的回覆)。

下面的腳本是我用來解決我的問題:

$from = [ADSI]"LDAP://CN=IT Department, OU=Technology Department, OU=Departments,DC=Company,DC=ca" 
$to = [ADSI]"LDAP://OU=Temporarily Moved Groups, DC=Company,DC=ca" 
$from.PSBase.MoveTo($to,"cn="+$from.name) 
+0

偉大的!感謝您發佈更新! – 2008-09-17 22:37:21

3

我沒有嘗試這樣呢,但是這應該這樣做..

$objectlocation= 'CN=IT Department, OU=Technology Department, OU=Departments,DC=Company,DC=ca' 
$newlocation = 'OU=Temporarily Moved Groups, DC=Company,DC=ca' 

$from = new-object System.DirectoryServices.DirectoryEntry("LDAP://$objectLocation") 
$to = new-object System.DirectoryServices.DirectoryEntry("LDAP://$newlocation") 
$from.MoveTo($newlocation,$from.name) 
相關問題