Werbung: SecurityConsole.de verwaltet Ihre Computer mit Security Essentails aus der Cloud!
30 Tage kostenfrei testen und 20% Rabatt für Ihre Bestellung mit Promocode: WBF2685582
(Promocode gültig bis 31.12.2011)

Group:  English: Windows Server » microsoft.public.windows.server.scripting
Thread: computer accounts in active directory

HTVi
TV Discussion Newsgroups

computer accounts in active directory
sircooljoe 5/9/2007 1:49:02 PM
Hello,
I need some help with a script. I am trying to get a list of all computer
accounts in my domain. I found the script in the respository, however it
just gives me a pop up window for each machine.
I am looking for a way to take this script and export the information into a
file.
Any help would be appreciated.

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=am,DC=wj,DC=MS,DC=lvmh' " _
& "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: computer accounts in active directory
J Ford 5/9/2007 3:41:01 PM
In order to avoid to popup you need to run it via command line

:/>cscript //nologo <scriptname>.vbs

then you can redirect the output to a file by adding "> <somename>.txt"

-J

"sircooljoe" wrote:

[Quoted Text]
> Hello,
> I need some help with a script. I am trying to get a list of all computer
> accounts in my domain. I found the script in the respository, however it
> just gives me a pop up window for each machine.
> I am looking for a way to take this script and export the information into a
> file.
> Any help would be appreciated.
>
> 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=am,DC=wj,DC=MS,DC=lvmh' " _
> & "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
>

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net
Suche nach Orten, Städten, Postleitzahlen, Vorwahlen, Kfz-Kennzeichen