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
Solved

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

Posted on 2011-09-28
4
326 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 53

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Script to copy or move mouse-selected collection of files plus targets referenced by shortcuts (.lnk) The purpose of this article is to help illuminate the real challenges and options available (where they may exist) for utilizing simple scriptin…
Well hello again!  Glad to see you've made it this far without giving up.  In this, the fourth installment of my popular series, I'm going to cover functions and subroutines, what they are, and why they are useful.  Just in case you stumbled onto th…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
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…

829 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