Solved

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

Posted on 2011-09-28
4
334 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: 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

Welcome back!  My apologies for taking so long to write part two of this series; it's been a long time coming!  As I promised in Part 1, this article will focus on how to locate those elusive AD properties that you are searching for.  Why is this us…
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…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

739 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