Receiving error :" Move-ADObject : The operation could not be performed because the object's parent is either uninstantiated or deleted"
My Script:
import-module activedirectory
import-csv c:\mylist.csv |
foreach-object{
$user=Get-AdUser $_.userid
$dn=$user.distinguishedname
$parent=([adsi]"LDAP://$dn").Parent.Replace('LDAP://','')
$newdn="OU=disabled accounts,$parent"
$newdn -replace "OU=Temporary Accounts,", ""
$user | Disable-ADAccount
$user | Move-ADObject -targetpath $newdn -targetserver mgw-2k3-dc1.xyz.com
}
So I tried specifying a -targetserver, I receive error:
Move-ADObject : Can't move objects with memberships across domain boundaries as on
ce moved, this would violate the membership conditions of the account group. Remov
e the object from any account group memberships and retry
I'm assuming I'll have to query for the DC they reside on and make that the target for each object?