Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have to clean up computer objects in our AD, and as all computernames has the username included (like pcuser1, nbuser2 and so on), I'm trying to figure out how to generate a complete AD userlist and then compare it to a complete computername list. Our user objects are consistent so this comparison would tell me, if a computer object does not compare to a user.

How should I proceed with this? I'm no pro at scripting but I assume some vbs or powershell could do the trick. It's the comparing part I'm not to keen on.

Some pseudo code could be:

get all usernames from AD > text1
get all computernames from AD > text2
traverse text1
   traverse text2
   if text1.line# is contained in text2.line# then
      text1.line# and text2.line# > output.txt
share|improve this question
    
Your domain computer names contain substrings of users names? Could you please clarify with an edit to your question. –  jscott Jan 28 '11 at 11:33
add comment

1 Answer

up vote 0 down vote accepted

I would not write my own script to do this. For one thing, the pseudocode that you wrote would be O-n-squared. There are plenty of available tools that can be combined to get what you want.

Use a tool like ldifde or csvde or dsquery to export the elements that you care about. Depending on your version of windows, those may be included or you may need to download a resource kit or support tools.. You can do further processing with Excel or a text editor to get the source files to look right, sort them, etc.

Then, use a tool like WinDiff or other GUI (or text-mode, if that's your thing) to compare them.

Although, re-reading your question, you could just do what most other admins do, and do an export of computer accounts that are over x days inactive and just delete those.

share|improve this answer
    
Thanks mfinni - I found what I needed in csvde and windiff. –  lyngsie Jan 28 '11 at 14:14
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.