Move-ADObject : The operation could not be performed because the object's parent is either uninstantiated or deleted


i borrowed code below , modified suit needs, getting error below, can assist.

getting error:

move-adobject : operation not performed because object's parent either uninstantiated or deleted

 

at c:\projects\ad_lockdown\ad_desktop_move_to_noncomp_ou.ps1:75 char:5
+     move-adobject -targetpath $targetou
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + categoryinfo          : notspecified: (cn=xxxxxxx,o...c=xxxxx,dc=net:adcomputer) [move-adobject], adexception
    + fullyqualifiederrorid : operation not performed because object's parent either uninstantiated or deleted,microsoft.activedirectory.management.commands.moveadobject

********replace xxxxx computer name , domain respectively.********

code:

*******************************************************************

                               

<#      
.notes  
#===========================================================================  
# script: move_servers_into__ad_lockdown.ps1   
# created with:   
# author:   
# date: 
# organization:  
# file name: move_systems_into__ad_lockdown.ps1  
# comments:  multiple computer account desired ou 
#===========================================================================  
.description  
        move computer objects desired ou 
        get-content c:\projects\ad_lockdown\computers.txt ( need have list of servers ) 
        sample list 
        pc1 
        pc2 
        pc3 


#>  


## import ad module if not exist 
if (! (get-module activedirectory)) 

write-host "importing ad module....." -fore green 
import-module activedirectory 
write-host "completed..............." -fore green 



## adding varibles 
$space   =  write-host "" 
$sleep   =  start-sleep -seconds 3 

## reading list of computers csv , loading variable  
$computers = get-content c:\projects\ad_lockdown\computers.txt
$path      = "c:\projects\ad_lockdown\computers.txt" 
## verification 
if (! (test-path $path)) { 

    write-host "list of computers  list txt not exist" 




## defining target path  

## laptop compliance moves, comment out not needed.
 $targetou   =  "ou=non-compliant,ou=laptop,ou=hw,dc=odcorp,dc=net"
## $targetou   =  "ou=obsolete,ou=laptop,ou=hw,dc=odcorp,dc=net" 

##desktop compliance moves, comment out not needed.
##$targetou   =  "ou=non-compliant,ou=workstation,ou=hw,dc=odcorp,dc=net"  
## $targetou   =  "ou=obsolete,ou=workstation,ou=hw,dc=odcorp,dc=net" 

$countpc    = ($computers).count  

$space   =  write-host "" 
$sleep   =  start-sleep -seconds 3 
write-host "this script move computer accounts" -fore green 
write-host "destination location (non-compliant )     " -fore green 

## provide details 
write-host "list of computers............." -fore green 
$computers 
write-host ".............................." -fore green 


## adding varibles 
$space   =  write-host "" 
$sleep   =  start-sleep -seconds 3 
 
## reading list of computers csv , loading variable  
$computers = get-content c:\projects\ad_lockdown\computers.txt
$path      = "c:\projects\ad_lockdown\computers.txt" 
## verification 
if (! (test-path $path)) { 
     
    write-host "list of computers  list txt not exist" 
 

 
 
## defining target path  

## laptop compliance moves, comment out not needed.
 $targetou   =  "ou=non-compliant,ou=laptop,ou=hw,dc=odcorp,dc=net"
## $targetou   =  "ou=obsolete,ou=laptop,ou=hw,dc=odcorp,dc=net" 

##desktop compliance moves, comment out not needed.
##$targetou   =  "ou=non-compliant,ou=workstation,ou=hw,dc=odcorp,dc=net"  
## $targetou   =  "ou=obsolete,ou=workstation,ou=hw,dc=odcorp,dc=net" 

$countpc    = ($computers).count  
 
$space   =  write-host "" 
$sleep   =  start-sleep -seconds 3 
write-host "this script move computer accounts" -fore green 
write-host "destination location (non-compliant )     " -fore green 
 
 
## provide details 
write-host "list of computers............." -fore green 
$computers 
write-host ".............................." -fore green 
$space   
$sleep 
foreach( $computer in $computers){ 
    write-host "moving computers..." 
    get-adcomputer "cn=$computer,ou=smart3,ou=laptop,ou=hw,dc=na,dc=odcorp,dc=net" | 
    move-adobject -targetpath $targetou 

 
$space   
$sleep 
 
write-host "$computers"
write-host "completed....................." -fore green 
write-host "moved $countpc systems........" 
write-host "destination ou $targetou......"

*************************************************************


it looks code not complete because don't see move-adobject gave error.

but error in this... make sure corresponds ou in ad.

$targetou   =  "ou=non-compliant,ou=laptop,ou=hw,dc=odcorp,dc=net"


did post help? please use "vote helpful", "mark answer" or "propose answer". thank you!



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Error: 0x80073701 when trying to add Print Services Role in Windows 2012 Standard

Disconnecting from a Windows Server 2012 R2 file sharing session on a Windows 7,8,10 machine

Event ID 64,77,1008 Certificates Events Windows Server 2008, 2008R2