Subscribe to Windows IT Pro

 

Get Newsletters

  • Get the Latest News
  • Product Updates
  • Helpful Tricks
  • Productivity Tips

Subscribe Now!

April 07, 2003 12:00 AM

AD and WMI Reporting

Use Csvde, Scriptomatic, and Excel to create easy-to-read reports
Windows IT Pro
InstantDoc ID #38401
Rating: (0)
Downloads
38401.zip

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.

Related Content:

ARTICLE TOOLS

Comments
    There are no comments to display. Be the first one!
You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

White Papers

Get your Windows 7 deployment off to the right start by implementing PC lockdown. A locked-down environment is easier and cheaper to support since users are less likely to make unnecessary changes to the core system configuration - read more here!

Essential Guides

Is your iSCSI "lossy"? The reality is that most off-the-shelf Ethernet hardware deployed for iSCSI can lose packets, resulting in slow performance or application downtime. Learn how to assess your current iSCSI infrastructure and engineer an advanced iSCSI SAN infrastructure.

Web Seminars

What's the best way to keep your network safe from malware? In this web seminar, security expert Greg Shields suggests an alternative method to the traditional blacklisting approach that is common with anti-virus and anti-malware solutions.

eLearning Series

We bring the experts direct to you to share their real-world perspective and expertise. During each event, three sessions stream in real time, so you can learn, ask questions, and get solutions.
Upcoming event: Getting the Most with Exchange 2010 with Paul Robichaux

Subscribe to Windows IT Pro!

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.