使用Powershell将Active Directory组移动到另一个OU
时间:2020-03-05 18:57:00 来源:igfitidea点击:
如何使用Powershell将活动目录组移动到另一个组织单位?
IE。
我想将" IT部门"组从:
(CN=IT Department, OU=Technology Department, OU=Departments,DC=Company,DC=ca)
到:
(CN=IT Department, OU=Temporarily Moved Groups, DC=Company,DC=ca)
解决方案
回答
我还没有尝试过,但是应该这样做。
$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)
回答
脚本非常接近正确(我非常感谢答复)。
以下脚本是我用来解决问题的脚本:
$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)