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 rowswhich contain the names of the PCs we've yet to connect todown 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 Excelreporting about AD and your WMI clients might actually become fun.
End of Article
Prev. page
1
2
3
[4]
next page -->
|