Export Site Server Query Names And ID Numbers To Excel

 

This Vbs script will prompt you for a site server name and site code and export your sites queries names as well as their appropriate query Id’s and comments to an excel spreadsheet.

 

Vbs Script:

 

 

Set objExcel = CreateObject("Excel.Application")

objExcel.Visible = True

objExcel.Workbooks.Add

intRow = 2

 

objExcel.Cells(1, 1).Value = "Query Name"

objExcel.Cells(1, 2).Value = "Query ID"

objExcel.Cells(1, 3).Value = "Query Comments"

 

strSiteServer = InputBox("Enter Site Server Name")

strSiteCode = InputBox("Enter Site Code")

 

Set objWMIService = GetObject("winmgmts://" & strSiteServer & "\root\sms\site_" & strSiteCode)

Set colItems = objWMIService.ExecQuery("Select * from SMS_Query")

For Each objItem in colItems

objExcel.Cells(intRow, 1).Value = objItem.Name

objExcel.Cells(intRow, 2).Value = objItem.QueryID

objExcel.Cells(intRow, 3).Value = objItem.Comments

intRow = intRow + 1

Next

 

objExcel.Range("A1:C1").Select

objExcel.Selection.Interior.ColorIndex = 19

objExcel.Selection.Font.ColorIndex = 11

objExcel.Selection.Font.Bold = True

objExcel.Cells.EntireColumn.AutoFit

 

Set objExcel = Nothing

Set objWMIService = Nothing

Set colItems = Nothing

 

MsgBox "Done"

 

Published Sunday, January 28, 2007 1:23 PM by dhite
Filed under:

Comments

No Comments