Mover grupo do Active Directory para outra UO usando Powershell
-
09-06-2019 - |
Pergunta
Como movo um grupo do Active Directory para outra unidade organizacional usando o Powershell?
ou seja.
Gostaria de mover o grupo "Departamento de TI" de:
(CN=IT Department, OU=Technology Department, OU=Departments,DC=Company,DC=ca)
para:
(CN=IT Department, OU=Temporarily Moved Groups, DC=Company,DC=ca)
Solução
Seu roteiro estava quase correto (e eu realmente aprecio sua resposta).
O script a seguir é o que usei para resolver meu problema:
$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)
Outras dicas
Ainda não tentei isso, mas deve servir.
$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)
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow