usslindstrom
asked on
Delete Multiple AD Computer Accounts via VBScript w/logging
I have the following vbscript that works for a single PC deletion.
What I'd like to do, is expand it so it loops through a text file that I have (let's say c:\systemlist.txt) for all the pc's on that list. And export the results (successful/unsuccesful) to a text file.
Would somebody be able to point me in the right direction for the script that's needed?
As always, thanks for helping.
What I'd like to do, is expand it so it loops through a text file that I have (let's say c:\systemlist.txt) for all the pc's on that list. And export the results (successful/unsuccesful) to a text file.
Would somebody be able to point me in the right direction for the script that's needed?
As always, thanks for helping.
strComputer = "####"
set objComputer = GetObject("LDAP://CN=" & strComputer & _
",CN=####,DC=####,DC=###")
objComputer.DeleteObject (0)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you very much for your assistance.
But please forgive me, I can't get the script to work.
The script returns all PCs in the txt file as "not found" - so I took the time to practice on some of my debugging. :) - please forgive my very basic understanding of vbscript...
But I added this line: wscript.echo(ComputerDN) to see what it would return, and the msgbox only returns a question mark.
Would you be able to help me get more out of this script when ya' get a chance? Thanks again for helping.
But please forgive me, I can't get the script to work.
The script returns all PCs in the txt file as "not found" - so I took the time to practice on some of my debugging. :) - please forgive my very basic understanding of vbscript...
But I added this line: wscript.echo(ComputerDN) to see what it would return, and the msgbox only returns a question mark.
Would you be able to help me get more out of this script when ya' get a chance? Thanks again for helping.
? means the account was not found.
Did you change line 1 to YOUR domain name?
Did you change line 1 to YOUR domain name?
ASKER
Yup - on changing the first line to my domain name. - I was just testing with my little "debug" addition to the script.
Now, I could be completely wrong in how I put my domain name. . . I just put the fqdn (domainname.com) etc. But does this need to be in the format "DC=domainname, DC=COM"?
On a serious note - thank you very much for taking your time to assist me. It's greatly appreciated.
Now, I could be completely wrong in how I put my domain name. . . I just put the fqdn (domainname.com) etc. But does this need to be in the format "DC=domainname, DC=COM"?
On a serious note - thank you very much for taking your time to assist me. It's greatly appreciated.
No, like I put in the code, you are only supposed to put the netbios name, not the FQDN..
ASKER
I'm missing something fundamental here.
Sorry to be so bothersome. I included some snapshots of "me at work" :) - but I think I'm still out of the loop on the mechanics involved.
DelAD.JPG
Sorry to be so bothersome. I included some snapshots of "me at work" :) - but I think I'm still out of the loop on the mechanics involved.
DelAD.JPG
Well, if you're going to scribble out all the relevant information, there's not much I can do to help.. LOL
ASKER
sorry - that's from my work. lol
Pretty much a mandatory thing if I post any questions about it. - sure does make it hard to ask questions too. lol
In this case, let's say my domain is "domainname.com" and the NETBIOS name is "DOMAINNAME"
Even if I put that in the script that was provided earlier, it can't locate any of the PCs on the list, however, when I search AD - they come up.
Pretty much a mandatory thing if I post any questions about it. - sure does make it hard to ask questions too. lol
In this case, let's say my domain is "domainname.com" and the NETBIOS name is "DOMAINNAME"
Even if I put that in the script that was provided earlier, it can't locate any of the PCs on the list, however, when I search AD - they come up.
You're right, it does make it difficult.
I don't know what to tell you, the code is good, and I can't see what's going on, so...
Good luck,
exx
I don't know what to tell you, the code is good, and I can't see what's going on, so...
Good luck,
exx
ASKER
Couldn't get much in the way of the NETBIOS resolution... But need to thank ya' - in taking the time to help me out.
I can imagine that when I get the netbios resolution worked out, that this script here will be great.
It's much appreciated.
I can imagine that when I get the netbios resolution worked out, that this script here will be great.
It's much appreciated.
ASKER