Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Query Domain

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

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Query Domain
  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 >>
 Query Domain - 2/21/2006 9:37:53 PM   
  bigfatgreedykat

 

Posts: 34
Score: 0
Joined: 2/2/2006
Status: offline
Hello

I have been able to create scripts that can query registry of local pc's.

Is there some way to query a whole domain?

I look forward to your replies and thanks in advance.

BFGK
 
 
Post #: 1
 
 RE: Query Domain - 2/24/2006 6:42:41 PM   
  bigfatgreedykat

 

Posts: 34
Score: 0
Joined: 2/2/2006
Status: offline
Hello

I have been able to figure out query domain using LDAP. This bring back a list of computer name. I have created a script that searches the registry.

My only problem now is putting the two scripts together.

Can anyone help?

BFGK

(in reply to bigfatgreedykat)
 
 
Post #: 2
 
 RE: Query Domain - 2/25/2006 9:12:58 AM   
  ebgreen


Posts: 5069
Score: 31
Joined: 7/12/2005
Status: offline
The first step would be for you to post your code.

_____________________________

"... 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 bigfatgreedykat)
 
 
Post #: 3
 
 RE: Query Domain - 2/26/2006 9:58:11 PM   
  bigfatgreedykat

 

Posts: 34
Score: 0
Joined: 2/2/2006
Status: offline
Here's the code

1. Query's the domain

Option Explicit
rem On Error Resume Next
Dim oQuery
Dim objConnection
Dim objCommand
Dim objRecordSet

oQuery = "<LDAP://dc=tcc,dc=local>;" & _
"(objectCategory=computer);" & _
"distinguishedName,name;subtree"
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Open "Provider=ADsDSOObject;"
objCommand.ActiveConnection = objConnection
objCommand.CommandText = oQuery
Set objRecordSet = objCommand.Execute
While not objRecordSet.EOF
WScript.Echo objRecordSet.Fields("name")
objRecordSet.MoveNext
Wend
objCOnnection.Close

2. Here the query registry code.

Dim strKeyPath
Dim strComputer
Dim strEntryName
Dim strValue
Dim strData
Dim objReg
Dim subKey
Dim arrSubKeys
Const HKLM = &H80000000 'HKEY_LOCAL_MACHINE
Dim oWsh:Set oWsh = CreateObject("WScript.Shell")


strData = oWsh.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\RegisteredOrganization")
If Err.Number = 0 Then
    WScript.Echo ("What " & strData)
Else
    WScript.Echo ("Nothing Exist " & Now)
End If



I hope the above can be put together, thanks in advance for all you help.

BFGK

(in reply to ebgreen)
 
 
Post #: 4
 
 RE: Query Domain - 2/27/2006 2:30:15 AM   
  ebgreen


Posts: 5069
Score: 31
Joined: 7/12/2005
Status: offline
The second script will not read a remote computer's registry. You would need to use WMI for that. Search this forum and you will find lots of sample WMI scripts.

_____________________________

"... 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 bigfatgreedykat)
 
 
Post #: 5
 
 RE: Query Domain - 2/27/2006 5:54:06 AM   
  bigfatgreedykat

 

Posts: 34
Score: 0
Joined: 2/2/2006
Status: offline
Hello

You are right i've created a WMI that can query registry.

Sub ListComputers
Dim objRegProv
Dim objWshController
Dim objRemoteScript
Dim strKeyPath
Dim strEntryName
Dim strValue
Dim strValueName
Dim strData
Dim objReg
Dim subKey
Dim arrSubKeys
Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Microsoft\Windows Script Host\Settings"
objReg.SetStringValue HKLM, strKeyPath, "Remote", "1"
strKeyPath2 = "SOFTWARE\INTEL\LanDesk\VirusProtect6\CurrentVersion"
strValueName = "Parent"
objReg.GetStringValue HKLM, strKeyPath2, strValueName, strData
WScript.Echo ("Anti-Virus Server " & strData) 
If strdata = "SLONSUPP" Then
WSCript.Echo ("Anti-Virus Server Correct")
ElseIf strdata ="SLONSUPP06" Then
WScript.Echo ("Anti-Virus Server incorrect please call x1966")
ElseIf strdata ="SLONSUPP03" Then
WScript.Echo ("Anti-Virus Server incorrect please call x1966")
Else
WScript.Echo ("No Anti-Virus Software installed")
End If
End Sub
Dim strComputer
rem Do
strComputer = inputbox ("Enter hostname of pc","Input")
rem if (Action ="") Then WScript.Quit
rem Loop until strComputer <>""
If strComputer = "" Then WScript.Quit
ListComputers

Above opens an input box but need to link this to LDAP query. Any ideas or a pointer in the right direction???

(in reply to ebgreen)
 
 
Post #: 6
 
 RE: Query Domain - 2/27/2006 9:57:46 AM   
  ebgreen


Posts: 5069
Score: 31
Joined: 7/12/2005
Status: offline
See if this helps:


      

_____________________________

"... 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 bigfatgreedykat)
 
 
Post #: 7
 
 
 
  

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 >> Query Domain 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