I copied the info below into notepad and saved the file as accounts.vbs to
the desktop. It's supposed to list all computer accounts in AD and I copied
it directly from scripts at MS.com.

I go to start-run and type in CMD for the command prompt

I navigate to the desktop and type in cscript accounts.vbs

The black command prompt screen only returns:

Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.



It's not giving me a list of computer accounts. What am I doing wrong???

Thanks for any info on this.

Bryce



---------------------------------------------------------------------------------------

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("Searchscope") = ADS_SCOPE_SUBTREE
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst

Do Until objRecordSet.EOF
Wscript.Echo "Computer Name: " & objRecordSet.Fields("Name").Value
Wscript.Echo "Location: " & objRecordSet.Fields("Location").Value
objRecordSet.MoveNext
Loop

RE: scripting question and no output by jefrie

jefrie
Wed Feb 22 11:26:27 CST 2006

hmm, you copied the script, saved it and executed it without modification ?!
So, your AD looks like DC=fabrikam,DC=com ?

You should use this with your path

"Select Name, Location from 'LDAP://DC=fabrikam,DC=com' " _
& "Where objectClass='computer'"

p.s. you can use dsquery for getting the right information

--
Jens Frieben (Germany)


"Bryce" wrote:

> I copied the info below into notepad and saved the file as accounts.vbs to
> the desktop. It's supposed to list all computer accounts in AD and I copied
> it directly from scripts at MS.com.
>
> I go to start-run and type in CMD for the command prompt
>
> I navigate to the desktop and type in cscript accounts.vbs
>
> The black command prompt screen only returns:
>
> Microsoft (R) Windows Script Host Version 5.6
> Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
>
>
>
> It's not giving me a list of computer accounts. What am I doing wrong???
>
> Thanks for any info on this.
>
> Bryce
>
>
>
> ---------------------------------------------------------------------------------------
>
> 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("Searchscope") = ADS_SCOPE_SUBTREE
> Set objRecordSet = objCommand.Execute
> objRecordSet.MoveFirst
>
> Do Until objRecordSet.EOF
> Wscript.Echo "Computer Name: " & objRecordSet.Fields("Name").Value
> Wscript.Echo "Location: " & objRecordSet.Fields("Location").Value
> objRecordSet.MoveNext
> Loop
>
>
>
>
>

Re: scripting question and no output by Richard

Richard
Wed Feb 22 11:30:23 CST 2006

Hi,

You need to substitute the DNS name of your domain for DC=fabrikam,DC=com.
For example, if your domain is MyDomain.com, use:

"Select Name, Location from 'LDAP://DC=MyDomain,DC=com' " _
& "Where objectClass='computer'"

--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net

"Bryce" <fukuzz@hotmail.com> wrote in message
news:uSK7$78NGHA.4052@TK2MSFTNGP15.phx.gbl...
>I copied the info below into notepad and saved the file as accounts.vbs to
>the desktop. It's supposed to list all computer accounts in AD and I copied
>it directly from scripts at MS.com.
>
> I go to start-run and type in CMD for the command prompt
>
> I navigate to the desktop and type in cscript accounts.vbs
>
> The black command prompt screen only returns:
>
> Microsoft (R) Windows Script Host Version 5.6
> Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
>
>
>
> It's not giving me a list of computer accounts. What am I doing wrong???
>
> Thanks for any info on this.
>
> Bryce
>
>
>
> ---------------------------------------------------------------------------------------
>
> 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("Searchscope") = ADS_SCOPE_SUBTREE
> Set objRecordSet = objCommand.Execute
> objRecordSet.MoveFirst
>
> Do Until objRecordSet.EOF
> Wscript.Echo "Computer Name: " & objRecordSet.Fields("Name").Value
> Wscript.Echo "Location: " & objRecordSet.Fields("Location").Value
> objRecordSet.MoveNext
> Loop
>
>
>
>



Re: scripting question and no output by Bryce

Bryce
Wed Feb 22 11:38:54 CST 2006

wow. that was dumb. thanks guys.

Bryce.


"Richard Mueller" <rlmueller-NOSPAM@ameritech.NOSPAM.net> wrote in message
news:usDErW9NGHA.2124@TK2MSFTNGP14.phx.gbl...
> Hi,
>
> You need to substitute the DNS name of your domain for DC=fabrikam,DC=com.
> For example, if your domain is MyDomain.com, use:
>
> "Select Name, Location from 'LDAP://DC=MyDomain,DC=com' " _
> & "Where objectClass='computer'"
>
> --
> Richard
> Microsoft MVP Scripting and ADSI
> Hilltop Lab - http://www.rlmueller.net
>
> "Bryce" <fukuzz@hotmail.com> wrote in message
> news:uSK7$78NGHA.4052@TK2MSFTNGP15.phx.gbl...
>>I copied the info below into notepad and saved the file as accounts.vbs to
>>the desktop. It's supposed to list all computer accounts in AD and I
>>copied it directly from scripts at MS.com.
>>
>> I go to start-run and type in CMD for the command prompt
>>
>> I navigate to the desktop and type in cscript accounts.vbs
>>
>> The black command prompt screen only returns:
>>
>> Microsoft (R) Windows Script Host Version 5.6
>> Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
>>
>>
>>
>> It's not giving me a list of computer accounts. What am I doing wrong???
>>
>> Thanks for any info on this.
>>
>> Bryce
>>
>>
>>
>> ---------------------------------------------------------------------------------------
>>
>> 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("Searchscope") = ADS_SCOPE_SUBTREE
>> Set objRecordSet = objCommand.Execute
>> objRecordSet.MoveFirst
>>
>> Do Until objRecordSet.EOF
>> Wscript.Echo "Computer Name: " & objRecordSet.Fields("Name").Value
>> Wscript.Echo "Location: " & objRecordSet.Fields("Location").Value
>> objRecordSet.MoveNext
>> Loop
>>
>>
>>
>>
>
>