Solved

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

Posted on 2011-09-28
4
312 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 52

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
Hello again, all.  For those of you that have been following along, you'll know that this is my third article on this topic (though it is not Part III).  This article is sort of remedial, and probably the topic with which I should have started the s…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

895 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now