Solved

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

Posted on 2011-09-28
4
301 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
Comment Utility
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 51

Expert Comment

by:Bill Prew
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Welcome to part one of a multi-part tutorial series, VBScript for Windows System Administrators.  The goal of this series is to teach non-programmers how to write useful VBS code to automate their environment, and perform tasks faster, and in a more…
Welcome, welcome!  If you are new to the series and haven't been following along, please take a brief moment to review the first three installments: Part 1 (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/A_266-VBScri…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

763 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

7 Experts available now in Live!

Get 1:1 Help Now