Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


listing computers

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,940
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> listing computers
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 listing computers - 1/4/2004 7:52:50 PM   
  mendingo

 

Posts: 1
Score: 0
Joined: 1/4/2004
From: United Kingdom
Status: offline
Is there a way to get a list of computers on a domain in vbscript, using LDAP or any other method?
 
 
Post #: 1
 
 Re: listing computers - 1/13/2004 9:03:05 AM   
  Co

 

Posts: 1
Score: 0
Joined: 1/13/2004
From: Netherlands
Status: offline
I know a tool called netview which can do the job:

http://www.optimumx.com/Download/

Co

A little knowledge is a dangerous thing

The only thing that helps me maintain my slender grip on reality is the
friendship I share with my collection of singing potatoes.

(in reply to mendingo)
 
 
Post #: 2
 
 Re: listing computers - 9/16/2004 4:22:11 AM   
  d4nclark

 

Posts: 4
Score: 0
Joined: 9/16/2004
From:
Status: offline
Just Joined But I wrote this script a while Back which kind of does what you want. Just Edit It As Neccessary...



On Error Resume Next



' Constant for the account being disabled
Const ADS_UF_ACCOUNTDISABLE = 2
' Constant for the search to search subtrees
Const ADS_SCOPE_SUBTREE = 2

Const adOpenStatic = 3
Const adLockOptimistic = 3

' General variable declarations
Dim objConnectionAD, objCommandAD, objRecordsetAD
Dim dtStart
Dim strSQL
Dim objRootDSE, strDNSDomain



' Get the start time of the script
dtStart = TimeValue(Now( ))


' Determine the DNS domain from the RootDSE object.
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("defaultNamingContext")

' Create and open an ADO connection to AD
Set objConnectionAD = CreateObject("ADODB.Connection")
Set objCommandAD = CreateObject("ADODB.Command")

objConnectionAD.Provider = "ADsDSOObject"
objConnectionAD.Open "Active Directory Provider"

' Set connection properties
With objCommandAD
.ActiveConnection = objConnectionAD

' Use SQL syntax for the query

.CommandText = _
"Select distinguishedName, name" & _
" FROM 'LDAP://" & strDNSDomain & "'" & _
" WHERE objectCategory = 'computer' " & _
" ORDER BY displayName"

end with
Set objRecordSetAD = objCommandAD.Execute

' Move to the first record in the recordset
objRecordSetAD.MoveFirst

' Loop until we reach the end of the recordset
Do While NOT objRecordsetAD.EOF
strDistinguishedName = objRecordsetAD("distinguishedName").value
strName = objRecordsetAD("Name").value




' Move to the next record in the AD recordset
objRecordsetAD.MoveNext
Loop


' Close the AD recordset
objRecordsetAD.Close
' Close the AD connection
objConnectionAD.Close

' Release these object references
Set objRecordsetAD = Nothing
Set objConnectionAD = Nothing

' Let the user know how long this process took
WScript.Echo "The script completed in approximately " & _
Second(TimeValue(now( )) - dtStart) & _
" seconds."

' That's all folks!
Wscript.Quit


ps. This script can also find list all Users in your AD just alter the SQL......

"Select distinguishedName, name" & _
" FROM 'LDAP://" & strDNSDomain & "'" & _
" WHERE objectCategory = 'user' " & _
" ORDER BY displayName"

(in reply to mendingo)
 
 
Post #: 3
 
 RE: listing computers - 8/16/2005 7:26:16 AM   
  KeithW

 

Posts: 2
Score: 0
Joined: 8/16/2005
Status: offline
I saw your script, and I have a similar one.  THe problem I have is when it gets to 1000 objects, it doesn't return any more after that.  I can manually set the Page Size parameter and then it will count the correct number of objects, but then the records set is apparently empty?  (EOF/BOF = true, AbsolutePosition and AbsolutePage = -1)

Ever work with large lists?

(in reply to mendingo)
 
 
Post #: 4
 
 RE: listing computers - 8/16/2005 11:48:17 AM   
  spar75


Posts: 8
Score: 0
Joined: 6/20/2005
From:
Status: offline
You can also get the listing within active directory. If you want to have the informationput  into a file all, you have to do is right click on the organizational unit that holds all the computer accounts (i.e. computers or workstations) and choose export to file.

(in reply to KeithW)
 
 
Post #: 5
 
 RE: listing computers - 8/16/2005 7:11:38 PM   
  ginolard


Posts: 1082
Score: 21
Joined: 8/10/2005
Status: offline
Shameless plug warning!!

You could also take a look at my ManagePC HTA in the "Post a Vbscript" forum.  It will import all machines from a domain and present you with various WMI data as well letting you perform several remote actions on the machine.

(in reply to spar75)
 
 
Post #: 6
 
 RE: listing computers - 8/16/2005 11:40:42 PM   
  mbouchard


Posts: 1924
Score: 16
Joined: 5/15/2003
From: USA
Status: offline
You could use WinNT

Dim WshShell : Set WshShell = WScript.CreateObject ("WSCript.shell")
Dim Fso : Set Fso = CreateObject("Scripting.FileSystemObject")
Dim F : Set F = Fso.CreateTextFile("c:\ComputersInDomain.txt", TRUE)

Set oContainer = GetObject("WinNT://YOURDOMAINNAMEHERE")
oContainer.Filter = Array("computer")
For Each oComputer1 in oContainer
      F.WriteLine(oComputer1.name)
Next
f.close
WshShell.Run "notepad.exe c:\ComputersInDomain.txt"

_____________________________

Mike

For useful Scripting links see the Read Me First stickey!

Always remember Search is your friend.

(in reply to ginolard)
 
 
Post #: 7
 
 RE: listing computers - 5/21/2007 2:25:20 AM   
  4scriptmoni


Posts: 208
Score: 0
Joined: 5/3/2007
Status: offline
cool code!
To automatic get the domain u can use:

Set objExecObject = objShell.Exec("cmd /c echo %USERDOMAIN%")
Do While Not objExecObject.StdOut.AtEndOfStream
           userdomain = objExecObject.StdOut.ReadLine()   'gets %userdomain%
           trim(userdomain)
loop

_____________________________

Enterprise Microsoft Scripts
Exchange, Login/Logout Monitor,TS, Monitoring, Security, AD, etc...
http://www.felipeferreira.net

(in reply to mbouchard)
 
 
Post #: 8
 
 RE: listing computers - 5/21/2007 2:30:00 AM   
  ebgreen


Posts: 5251
Score: 31
Joined: 7/12/2005
Status: offline
Or two ways to get the domain without shelling out:

Option Explicit
Dim oWsh:Set oWsh = CreateObject("WScript.Shell")
Dim oWSN:Set oWSN = CreateObject("WScript.Network")

WScript.Echo oWsh.ExpandEnvironmentStrings("%USERDOMAIN%")
WScript.Echo oWSN.UserDomain

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to 4scriptmoni)
 
 
Post #: 9
 
 RE: listing computers - 6/17/2007 8:51:56 PM   
  4scriptmoni


Posts: 208
Score: 0
Joined: 5/3/2007
Status: offline
I have two methods I used in my .hta script to get computer lists.
One uses LDAP query if in Domain enviroment another uses the net view command,
my third one will be the IP scan.
Well here it:


      

and the LDAP query way


      

salute,

FF

< Message edited by 4scriptmoni -- 6/17/2007 9:10:08 PM >


_____________________________

Enterprise Microsoft Scripts
Exchange, Login/Logout Monitor,TS, Monitoring, Security, AD, etc...
http://www.felipeferreira.net

(in reply to mendingo)
 
 
Post #: 10
 
 RE: listing computers - 6/17/2007 8:57:12 PM   
  ginolard


Posts: 1082
Score: 21
Joined: 8/10/2005
Status: offline
Check the ADQuery Template script from my sig.  

_____________________________

Author of ManagePC - http://managepc.net
AD Query Template - http://www.visualbasicscript.com/m_40609/tm.htm
Consolidated Scripting Framework - http://www.visualbasicscript.com/m_59109/tm.htm

(in reply to 4scriptmoni)
 
 
Post #: 11
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> listing computers Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts