Solved

VBS script return only computers with "TAG" in the name

Posted on 2011-09-28
4
331 Views
Last Modified: 2012-05-12
I need a VBS script that will search the domain computers on the network and return an excel file with TAG in the computer name. Thanks for you help in advance.
0
Comment
Question by:Sleepydog
  • 2
4 Comments
 
LVL 65

Accepted Solution

by:
RobSampson earned 250 total points
ID: 36725339
Hi, try this.

Regards,

Rob.
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objNetwork = CreateObject("WScript.Network")
Set objComputers = GetObject("WinNT://" & objNetwork.UserDomain)
objComputers.Filter = Array("Computer")
Set objOutputFile = objFSO.CreateTextFile("TagComputers.csv", True)
For Each objComputer In objComputers
	If InStr(LCase(objComputer.Name), "tag") > 0 Then objOutputFile.WriteLine objComputer.Name
Next
objOutputFile.Close
Set objOutputFile = Nothing
MsgBox "Done"

Open in new window

0
 
LVL 54

Expert Comment

by:Bill Prew
ID: 36741989
You could also use the excellent freeware utility ADFIND and do something like this.  It also supports output to CSV which could then be opened in Excel.

adfind -default -f "(&(objectcategory=computer)(name=*TAG*))"

website is at:

http://www.joeware.net/freetools/tools/adfind/index.htm

~bp
0
 
LVL 1

Author Closing Comment

by:Sleepydog
ID: 36812980
This is a good solution but it only tell me what computers are in AD not which ones are active on the network currently. Maybe I should have been more clear in my question.  Thank this is 80% of what I needed.
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 36813000
Yes, we could have had the script ping each pc to determine whether it's online....

If you raise another question, let us know...

Rob.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is an addendum to the following article: Acitve Directory based Outlook Signature (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_24950055.html) The script is fine, and works in normal client-server domains…
This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question