This Vbs script will take an SMS site server name and site code from an input box and then enumerate all of the Queries on that server. It will then add them to a Microsoft Word document that you can save for future reference.
VBS Script:
strComputer = InputBox ("Enter Site Server Name")
strSiteCode = InputBox("Enter Site Code")
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
Const wdAlignParagraphCenter = 1
Const wdAlignParagraphLeft = 0
Const wdColorGreen = 32768
Const wdColorBlue = 16711680
Const wdColorBlack = 0
Const wdColorGray = 15132390
Set objDoc = objWord.Documents.Add()
Set objSelection = objWord.Selection
objSelection.Font.Bold = True
objSelection.Font.Color = wdColorGreen
objSelection.ParagraphFormat.Alignment = wdAlignParagraphCenter
objSelection.TypeText "SMS Queries For " & UCase(strComputer)
objSelection.Font.Bold = False
objSelection.TypeParagraph()
objSelection.TypeText "Report Created: " & Date
objSelection.ParagraphFormat.Alignment = wdAlignParagraphLeft
Set objWMIService = GetObject("winmgmts://" & strComputer & "\root\sms\site_" & strSiteCode)
Set colItems = objWMIService.ExecQuery("Select * from SMS_Query")
For Each objItem in colItems
objSelection.Font.Color = wdColorBlue
objSelection.ParagraphFormat.Shading.BackgroundPatternColor = wdColorGray
objSelection.TypeText objItem.Name
objSelection.Font.Color = wdColorBlack
objSelection.TypeText objItem.Expression
Next
objSelection.TypeText "Created by Don Hite For myITforum.Com"
Additional Information:
VBS Script To Export SMS Web Reports To Microsoft Word
http://myitforum.com/cs2/blogs/dhite/archive/2006/11/28/vbs-script-to-export-sms-web-reports-to-microsoft-word.aspx
Interesting: myitforum.com
Thanks, but these queries do not include the collections (collection queries/code) that we need to backup. We rarely use the queries feature of SMS, but of course the queries within our collections are extremely important! Isn't there a table holding these collection queries somewhere? It would be great to see a VB script that could extract these.
Thanks.
This Vbs script will take an SMS site server name and site code from an input box and then enumerate
This Vbs script is based on a previous post found below that will take an SMS site server name, site