Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Server > Scripting > Retrive operatingSystem from Active Directory

Reply
Thread Tools Display Modes

Retrive operatingSystem from Active Directory

 
 
Jesper Ravn
Guest
Posts: n/a

 
      10-29-2009

Hello

How can i retrive operatingSystem from a specific computer/server.
Please see my code below.

Dim StrComputer as string
StrComputer = "SQLserver01"

adoCommand.CommandText = "SELECT Name, operatingSystem FROM " _
& "'LDAP://DC=DOMAIN,DC=COM' WHERE objectClass='computer' " _
& "and Name = " & StrComputer & ""

adoRecordset = adoCommand.Execute

Dim strOperatingSystem As String
strOperatingSystem = adoRecordset.Fields("operatingSystem").Value

It fails when running the execute command.
Hopefully you can me in the right direction.

Thanks;

/Jesper



 
Reply With Quote
 
 
 
 
Jesper Ravn
Guest
Posts: n/a

 
      10-29-2009
"Jesper Ravn" <> skrev i meddelelsen
news:#...
> Hello
>
> How can i retrive operatingSystem from a specific computer/server.
> Please see my code below.
>
> Dim StrComputer as string
> StrComputer = "SQLserver01"
>
> adoCommand.CommandText = "SELECT Name, operatingSystem FROM " _
> & "'LDAP://DC=DOMAIN,DC=COM' WHERE objectClass='computer' " _
> & "and Name = " & StrComputer & ""
>
> adoRecordset = adoCommand.Execute
>
> Dim strOperatingSystem As String
> strOperatingSystem = adoRecordset.Fields("operatingSystem").Value
>
> It fails when running the execute command.
> Hopefully you can me in the right direction.


Ok, I found the solution. It was a syntax error

adoCommand.CommandText = "Select Name, operatingSystem From " & _
LDAP://DC=Domain,DC=Com' Where objectClass='computer'" & _
" and Name = '" & StrComputer & "'"

/Jesper

 
Reply With Quote
 
Pegasus [MVP]
Guest
Posts: n/a

 
      10-29-2009

"Jesper Ravn" <> wrote in message
news:...
> "Jesper Ravn" <> skrev i meddelelsen
> news:#...
>> Hello
>>
>> How can i retrive operatingSystem from a specific computer/server.
>> Please see my code below.
>>
>> Dim StrComputer as string
>> StrComputer = "SQLserver01"
>>
>> adoCommand.CommandText = "SELECT Name, operatingSystem FROM " _
>> & "'LDAP://DC=DOMAIN,DC=COM' WHERE objectClass='computer' " _
>> & "and Name = " & StrComputer & ""
>>
>> adoRecordset = adoCommand.Execute
>>
>> Dim strOperatingSystem As String
>> strOperatingSystem = adoRecordset.Fields("operatingSystem").Value
>>
>> It fails when running the execute command.
>> Hopefully you can me in the right direction.

>
> Ok, I found the solution. It was a syntax error
>
> adoCommand.CommandText = "Select Name, operatingSystem From " & _
> LDAP://DC=Domain,DC=Com' Where objectClass='computer'" & _
> " and Name = '" & StrComputer & "'"
>
> /Jesper


Your updated code still has syntax problems - you've got unmatched
single/double quotes.


 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Active Sync File Directory John Gregory ActiveSync 1 05-14-2008 08:48 PM
active directory console Tracy Rich Windows Vista Administration 4 03-24-2008 07:13 PM
Windows Vista Bitlocker Active Directory Schema Ragnar Windows Vista Installation 6 02-01-2007 09:59 AM
Re: Active Directory Users and Computers missing Terminal Services Pro Richard G. Harper Windows Vista Installation 0 12-15-2006 10:21 PM
Managing Active Directory Kyle Windows Vista Administration 0 11-08-2006 07:21 PM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59