2012-02-17 41 views
0

如何使用System.DirectoryServices命名空間將用戶從一個OU移動到另一個?System.DirectoryServices命名空間 - >移動用戶OU?

我知道如何通過CMDLETs和舊的PSBase.moveto方式。這是唯一的方法嗎?我試圖避免CMDlets和PSBase.moveto。

奔看着http://msdn.microsoft.com/en-us/library/gg145037.aspx

任何人都知道嗎?

+0

除非我錯過了一些東西,這不是你已經問過的同一個問題嗎? – EBGreen 2012-02-17 13:49:55

+1

[Powershell NON-Cmdlet:通過System.DirectoryServices命名空間將用戶移動到新的OU]的可能重複(http://stackoverflow.com/questions/9315209/powershell-non-cmdlet-move-user-to-new-ou- via-system-directoryservices-namespac) – EBGreen 2012-02-17 13:51:03

+0

啊,是啊,現在當我再次看了以爲它被刪除了!這個問題的原因是因爲我必須在其他域中註冊我的su帳戶。 – 2012-02-17 14:31:12

回答

1

給你:

# MoveObject 
$OuDest=[ADSI] "LDAP://mach:389/ou=Commerciaux,dc=societe,dc=fr" 
$objUODest.MoveHere("LDAP://cn=Mickey,ou=Ventes,dc=societe,dc=fr", 「cn=Mickey") 

而且

# Rename 
$Ou=[adsi] "LDAP://mach:389/ou=Ventes,dc=societe,dc=fr" 
$Ou.MoveHere("LDAP://cn=PetitMickey,ou=Ventes,dc=societe,dc=fr", "cn=PetitMickeyBis") 

編輯

如果您需要authentify:

$OuDest = New-Object System.DirectoryServices.DirectoryEntry ("LDAP://FQDN name or @IP",$User,$password) 
$OuDest = New-Object System.DirectoryServices.DirectoryEntry ("LDAP://mach:389/ou=Commerciaux,dc=societe,dc=fr",$User,$password) 
+0

我不斷收到訪問被拒絕。我需要通過該域名上的我的SU帳戶運行命令,我不知道要在$ username和$ password變量中保留哪些位置:/ – 2012-02-17 14:32:11

+0

我編輯以解釋如何驗證。 – JPBlanc 2012-02-17 14:40:42