Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Query AD and for each machine frin out the adobe version

Reply
 
Old 08-27-2008   #1 (permalink)
freddy


 
 

Query AD and for each machine frin out the adobe version

VBscript to query AD and for each machine frin out the adobe version. Here is
my script:

Const ADS_SCOPE_SUBTREE = 2
Const ForWriting = 2

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
'Text File
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile =
objFSO.CreateTextFile("U:\Scripts\Get_Computer_names\AD_Computers_STMDRS_7_7_08.txt", ForWriting)
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"

Set objCOmmand.ActiveConnection = objConnection
objCommand.CommandText = _
"Select Name, Location from 'LDAP://OU=Desktops,OU=Workstations,OU=legg
mason,dc=leggmason,dc=com' " _
& "Where objectClass='computer' AND sAMAccountName='stmts*'"
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst

Do Until objRecordSet.EOF
Wscript.Echo "Computer Name: " & objRecordSet.Fields("Name").Value
'strComputer = objRecordSet.Fields("Name").Value
objRecordSet.MoveNext
'----------------------------------------------

strComputer = objRecordSet.Fields("Name").Value
Set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colSoftware = objWMI.ExecQuery( _
"SELECT Version FROM Win32_Product WHERE Name Like 'Adobe %'")
For Each objSoftware In colSoftware
WScript.echo objSoftware.name & vbtab & _
objSoftware.Version
Next
'-----------------------------------------------------
Loop

When I run the script it goes to the first machine and echos the version but
when it goes to the second machine I get an error: Microsoft VBScript
runtime error: The remote server machine does not exist or is unavailable:
'GetObject'

I can ping the second machine and remote to it. Can someone please help me.
also I want to ping the machine before it trys to get the version

Thanks

My System SpecsSystem Spec
Old 08-27-2008   #2 (permalink)
Richard Mueller [MVP]


 
 

Re: Query AD and for each machine frin out the adobe version


"freddy" <freddy@xxxxxx> wrote in message
news:048CD0A8-22B1-4C06-AFF8-BFC30E35A864@xxxxxx
Quote:

> VBscript to query AD and for each machine frin out the adobe version. Here
> is
> my script:
>
> Const ADS_SCOPE_SUBTREE = 2
> Const ForWriting = 2
>
> Set objConnection = CreateObject("ADODB.Connection")
> Set objCommand = CreateObject("ADODB.Command")
> 'Text File
> Set objFSO = CreateObject("Scripting.FileSystemObject")
> Set objFile =
> objFSO.CreateTextFile("U:\Scripts\Get_Computer_names\AD_Computers_STMDRS_7_7_08.txt",
> ForWriting)
> objConnection.Provider = "ADsDSOObject"
> objConnection.Open "Active Directory Provider"
>
> Set objCOmmand.ActiveConnection = objConnection
> objCommand.CommandText = _
> "Select Name, Location from 'LDAP://OU=Desktops,OU=Workstations,OU=legg
> mason,dc=leggmason,dc=com' " _
> & "Where objectClass='computer' AND sAMAccountName='stmts*'"
> objCommand.Properties("Page Size") = 1000
> objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
> Set objRecordSet = objCommand.Execute
> objRecordSet.MoveFirst
>
> Do Until objRecordSet.EOF
> Wscript.Echo "Computer Name: " & objRecordSet.Fields("Name").Value
> 'strComputer = objRecordSet.Fields("Name").Value
> objRecordSet.MoveNext
> '----------------------------------------------
>
> strComputer = objRecordSet.Fields("Name").Value
> Set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
> Set colSoftware = objWMI.ExecQuery( _
> "SELECT Version FROM Win32_Product WHERE Name Like 'Adobe %'")
> For Each objSoftware In colSoftware
> WScript.echo objSoftware.name & vbtab & _
> objSoftware.Version
> Next
> '-----------------------------------------------------
> Loop
>
> When I run the script it goes to the first machine and echos the version
> but
> when it goes to the second machine I get an error: Microsoft VBScript
> runtime error: The remote server machine does not exist or is unavailable:
> 'GetObject'
>
> I can ping the second machine and remote to it. Can someone please help
> me.
> also I want to ping the machine before it trys to get the version
>
> Thanks
A couple of things. First, I have several example functions to ping
computers linked here:

http://www.rlmueller.net/PingComputers.htm

Next, the "objRecordset.MoveNext" statement should be just before the "Loop"
statement. Otherwise you will skip the first computer and the name echo'd by
the Wscript.Echo command will be different from the computer being connected
to.

Also, you are retrieving the "Name" property of the computer objects, which
may not be the same as the NetBIOS name you need. True, the Name property
almost always is the same as the NetBIOS name, but it may not be. I would
use the sAMAcountName attribute instead and strip off the trailing "$". The
value of the sAMAccountName attribute is always the NetBIOS name of the
computer with the character "$" appended to the end.

Finally, the "Like" operator may not be supported on all clients. I cannot
remember which OS first supported it.

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Adobe flashplayer version old? Software
Latest Version of Adobe Shockwave Software
Machine Query PowerShell
Query machine OS's within an OU PowerShell
Can't run Adobe Reader, Any version. Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

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