• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1172
  • Last Modified:

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

0
Daltonjoe
Asked:
Daltonjoe
  • 2
1 Solution
 
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
 
Toni UranjekConsultant/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

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now