How do I move an active directory group to another organizational unit using Powershell?
ie.
I would like to move the group "IT Department" from:
(CN=IT Department, OU=Technology Department, OU=Departments,DC=Company,DC=ca)
to:
(CN=IT Department, OU=Temporarily Moved Groups, DC=Company,DC=ca)
Your script was really close to correct (and I really appreciate your response).
The following script is what I used to solve my problem.:
$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)
I haven't tried this yet, but this should do it..
$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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With