|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Newbie here,
I'm looking for a way to list all computers in a specific OU and the dump the output to an excel file. Can someone me with this. thanks, rt |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
rt wrote:
> Newbie here, > I'm looking for a way to list all computers in a specific OU and the dump > the output to an excel file. Can someone me with this. A simple VBScript program can bind to the OU, filter on computer objects, then output NetBIOS names (or the values of whatever attributes you want), one computer per line. If you output more than one attribute per computer, delimit them with a character that will not be in any attribute values. Such a file can be easily read into a spreadsheet. For example: ============ ' Bind to OU, specified by Distinguished Name. Set objOU = GetObject("LDAP://ou=Sample,ou=West,dc=MyDomain,dc=com") ' Filter on computer objects. objOU.Filter = Array("computer") ' Enumerate all computers in the OU. For Each objComputer In objOU Wscript.Echo objComputer.cn Next =========== If this VBScript is saved in the file EnumComputers.vbs, run it at a command prompt with cscript and redirect the output to a text file: cscript //nologo EnumComputers.vbs > computers.csv I used the cn (Common Name) attribute above. You can use objComputer.sAMAccountName, which is the NetBIOS name of the computer with "$" appended on the end. Or you can use objComputer.distinguishedName. If you want the script to create and write values to a Microsoft Excel spreadsheet, you can use the following example as a template: http://www.rlmueller.net/Write%20to%20Excel.htm Also, you can use Joe Richards' free adfind utility. It can retrieve objects matching a filter in a base OU and output to a csv file. http://www.joeware.net/win/free/tools/adfind.htm I think some other command line tools could be used as well, but adfind is the best. -- Richard Mueller Microsoft MVP Scripting and ADSI Hilltop Lab - http://www.rlmueller.net -- |
|
![]() |
| Outils de la discussion | |
|
|