When you need to extract Active Directory (AD) or Windows Management Instrumentation (WMI) data, several tools are at your disposal. The Csvde command-line utility (csvde.exe) and the Scriptomatic tool (scriptomatic.exe) are both extremely useful in this respect. To get the most out of this data, you can use Microsoft Excel to format the output into clean and easy-to-read reports. Here are some scripts to show you how.
AD Reporting
Csvde, which resides in %systemroot%\system32 after you install Windows Server 2003 or Windows 2000 Server, lets you import and export AD data to a comma-separated value (CSV) file according to attribute and object filters. For example, to extract all user-object data to a .csv file called C:\report.csv, open a command window and type the following command:
csvde -f c:\report.csv -v -d
"dc=mycorp,dc=com"
-r "(objectClass=User)" -p SubTree
This command directs Csvde to extract the information to the specified file (-f), use verbose mode onscreen while running (-v), start from mycorp.com's root (-d), look for the specified objects (i.e., User objects) only (-r), and scan the whole tree (-p). If you want to extract the user objects' ADsPath property only, add the following parameter:
-l ADsPath
For more information about Csvde's syntax, use the tool's -? parameter, type the csvde command with no parameters, or go to http://www.microsoft.com/technet/prodtechnol/windowsnetserver/proddocs/entserver/csvde.asp.
After you've used Csvde to extract AD information, the best method for making that data into legible reports (with formatted columns, headings, and so forth) is to use Excel. You can import the .csv file into Excel, then save the report as an Excel (.xls) file. I've created a VBScript script, which Listing 1, page 2, shows, that automates this process without visibly opening Excel. The script creates an Excel Application object, then uses the Workbooks::Open method to open the .csv file that I used Csvde to create (i.e., C:\report.csv). The script then passes two parameters to the ActiveWorkbook::SaveAs method. The first parameter specifies the new file to be created (i.e., C:\report.xls), and the second parameter defines the file format (i.e., xlNormal). Note that running this script on a Win2K Server that doesn't run Excel will result in an error.
System Reporting
If you're considering extracting system data for reporting purposes, investigate Scriptomatic, which automates the creation of complex WMI reporting scripts. (For information about WMI scripts and other reporting topics, see "Related Reading," page 2.) You can download this free tool from http://www.microsoft.com/technet/treeview/default.asp?url=/technet/scriptcenter/wmimatic.asp (at the time of this writing, the tool is also scheduled to be included in the Windows 2003 resource kit). Scriptomatic works on Windows 2003, Windows XP, and Win2K systems and on Windows NT 4.0 Service Pack 6 (SP6) and Windows 98 systems on which you've installed Microsoft Internet Explorer (IE) 5.0, WMI, and Windows Script Host (WSH) 5.6. You can use the tool to generate basic WMI scripts, which you can then modify to be more versatile.
Prev. page  
[1]
2
3
4
next page