Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get Registry settings of comps on domain?

Status
Not open for further replies.

dhmehrotra

Programmer
Sep 26, 2002
2
US
Hi,

I am a beginner at VBScript. So, if my question seems stupid - please excuse :)

Anyhow, what I'm trying to do is to get the Operating System (Windows) product ID of all the computers on our domain.

I looked at certain examples to see how I can get it for my local machine-


Set ws = WScript.CreateObject("WScript.Shell")
v = ws.RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductId")
WScript.Echo v


and I looked at certain examples online to see how network information can be gathered-



On Error Resume Next
Set prov = GetObject("WinNT:")

For each dom in prov
For each o in dom
If o.Class = "Computer" Then
WScript.Echo o.Class & o.Name & " \n" & " Owner: " & o_Owner
WScript.Echo " Division: " & o.Division
WScript.Echo " OperatingSystem: " & o_OperatingSystem
WScript.Echo " OS Version: " & o_OperatingSystemVersion
WScript.Echo " Processor: " & o.Processor
WScript.Echo " ProcessorCount: " & o.ProcessorCount
End if
Next
Next



But I am clueless, how I can merge both the above objectives to get the Product ID (from the registry) of all the systems on our domain.

Hope someone can help.

Thanks,
Dhruv
 
Code below from technet scripting

You can read the active directory to identify all computers in a domain and the query each one.


Const ADS_SCOPE_SUBTREE = 2
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCOmmand.ActiveConnection = objConnection
objCommand.CommandText = _
"Select Name, Location from 'LDAP://DC=fabrikam,DC=com' " _
& "where objectClass='computer'"
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Timeout") = 30
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.Properties("Cache Results") = False
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
strComputer = objRecordSet.Fields("Name").Value
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
Wscript.Echo objOperatingSystem.Caption & " " & objOperatingSystem.Version & strcomputer
Next
Loop

Regards
Steve Friday
 
Steve-

Thanks for your reply.

However, I am still not sure how would I be able to query EACH computer on the domain the get that computer's registry settings as I get it for my local computer (i.e how would I be able to do the following for each computer in the domain: ws.RegRead(&quot;HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductId&quot;) <- this way i am able to get it for my local machine)?

Also, the above code that you sent me only works for the first computer on the domain and does not get any information for subsequent computers. Any suggestions?

Dhruv
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top