SideBar    Formatting the Reports
DOWNLOAD THE CODE:
Download the Code 38401.zip

When looping through colItems, the script sets the first cell of the current row to be strComputer and the second and third cells to be the Caption and the Version, respectively. If colItems returns more than one result, the script moves all the following rows—which contain the names of the PCs we've yet to connect to—down to make room for this data. At the same time, the script adds the first cell, containing the strComputer value, to these new blank rows. So for example, if colItems contains three results, the script will fill in Row 2 with the first set of data from colItems, create a blank Row 3, insert strComputer and the next set of data from colItems into Row 3, create a blank Row 4, insert strComputer and the last set of data from colItems into Row 4, and create a blank Row 5. When the loop determines that colItems is empty and that we therefore don't need that final blank row, the script deletes that row. The next row, which contains the next PC, moves up, and the script continues.

Last, the script autofits the columns and rows, saves the .xls file, and opens it for viewing. You can just as easily have the script quit Excel without displaying the file to the user and instead send an email message notifying the user that the file is available. You can even have the script email the file, then remove it from the PC that the script ran on.

Reports in a Flash
To see a large amount of data for each PC, modify the script that Listing 3 shows so that it uses the Win32_Service class and the Description property, then watch what happens. (I strongly suggest that you limit the number of clients you connect to for this test, because these changes add one line per service per PC, or as many as 100 more lines per client.) Rather than using Csvde, comment out the lines at callout A in Listing 3 and reference an existing .csv file that contains a dozen or so PC names. This test will give you more than 1000 lines in your spreadsheet. Pretty powerful stuff, isn't it? Play around with Csvde, Scriptomatic, and Excel—reporting about AD and your WMI clients might actually become fun.


Related Reading
You can obtain the following article from Windows & .NET Magazine's Web site at http://www.winnetmag.com.

ALISTAIR G. LOWE-NORRIS
"Generating Deployment Reports," March 2000, InstantDoc ID 8054
You can obtain the following articles from the Windows Scripting Solutions Web site at http://www.winscriptingsolutions.com.

ALISTAIR G. LOWE-NORRIS
"Scripting Solutions with WSH and COM: Creating Simple and Useful Scripts with WMI," August 2000, InstantDoc ID 9173

"Scripting Solutions with WSH and COM: Simple Uses of WMI," July 2000, InstantDoc ID 8985

"Graphing Windows 2000 User Logons with Excel 2000," May 2000, InstantDoc ID 8601

"Using Excel Objects to Manipulate a Spreadsheet," April 2000, InstantDoc ID 8387

"Using WSH with ADSI to Create Excel Spreadsheets for Debugging," April 2000, InstantDoc ID 8385

"Automating Excel to Create Trend Charts," March 2000, InstantDoc ID 8186

End of Article

Prev. page     1 2 3 [4]     next page -->



You must log on before posting a comment.

If you don't have a username & password, please register now.