Skip to content

Instantly share code, notes, and snippets.

@tostka
Created July 17, 2019 23:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tostka/45be4596531bf449c617ebd295806894 to your computer and use it in GitHub Desktop.
Save tostka/45be4596531bf449c617ebd295806894 to your computer and use it in GitHub Desktop.
Move ADUser to non-replicated OU
# populate the DistName string below with a DN pointed at the target unreplicated OU
$tOU=get-adobject -Identity 'OU=Workspace,DC=SUBDOMAIN,DC=ad,DC=DOMAIN,DC=com' ;
# store the original ADUser object parentOU (split DN and build the parent OU)
$origOU=($adu.distinguishedname.split(",") | select -skip 1) -join "," ;
# move the ADUser object to the $tOU, note -whatif needs to be removed to execute
Move-ADObject -Identity $adu.ObjectGUID.guid -TargetPath $tOU.DistinguishedName -whatif ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment