This Vbs script will take an SMS site server name and site code from an input box and then enumerate all of the System queries on that server and read their corresponding WQL Queries. It will then write 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 WQL System Resource 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 Where TargetClassName = 'SMS_R_System'")
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"
VBS Script To Export SMS Queries To Microsoft Word
http://myitforum.com/cs2/blogs/dhite/archive/2008/02/24/vbs-script-to-export-sms-queries-to-microsoft-word.aspx
No Comments