dsquery | dsrm what´s wrong with my syntax

When I try to run my below syntax I get this error:
"Are you sure you wish to delete all children of OU=Desktops,OU=Workstations,OU=045HO,OU=Locations,DC
=velux,DC=org (Y/N)? dsrm failed:OU=Desktops,OU=Workstations,OU=045HO,OU=Locations,DC=velux,DC=org:T
he handle is invalid."
dsquery computer OU=Desktops,OU=Workstations,OU=045HO,OU=Locations,DC=velux,DC=org -inactive 50 -limit 0 | dsrm "OU=Desktops,OU=Workstations,OU=045HO,OU=Locations,DC=velux,DC=org" -subtree -exclude -c

Open in new window

DaltonjoeAsked:
Who is Participating?
 
Toni UranjekConnect With a Mentor Consultant/TrainerCommented:
I have posted exact command in my first comment. I've attached it again as code sinppet. First part of command "dsquery computer OU=Desktops,OU=Workstations,OU=045HO,OU=Locations,DC=velux,DC=org -inactive 50 -limit 0" will list all old computer accounts, "dsrm" will remove them. That's it.
dsquery computer OU=Desktops,OU=Workstations,OU=045HO,OU=Locations,DC=velux,DC=org -inactive 50 -limit 0 | dsrm

Open in new window

0
 
Toni UranjekConsultant/TrainerCommented:
Hi!

Use only "dsquery computer OU=Desktops,OU=Workstations,OU=045HO,OU=Locations,DC=velux,DC=org -inactive 50 -limit 0 | dsrm" if you are trying to delete old computer accounts. Your dsrm part of command is trying to delete an OU.

HTH

Toni
0
 
DaltonjoeAuthor Commented:
Hi Toniur
 
Thanks for your comment.
How can I then combine my dsquery with a "auto " deletion of in thsi example computers?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.