The VBS script below will allow you to send the Software Metering properties for your site to an Excel spreadsheet as viewed in the ConfigMgr Software Metering leaf. The second script will provide the same information for those that are Enabled.
VBS Script To Enumerate Software Metering Properties
strServer = InputBox ("Enter Site Server Name")
strDatabase = InputBox ("Enter Three Letter Site Code")
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.Workbooks.Add
intRow = 2
objExcel.Cells(1, 1).Value = "Name"
objExcel.Cells(1, 2).Value = "Original File Name"
objExcel.Cells(1, 3).Value = "File Name"
objExcel.Cells(1, 4).Value = "File Version"
objExcel.Cells(1, 5).Value = "Language ID"
objExcel.Cells(1, 6).Value = "Site Code"
objExcel.Cells(1, 7).Value = "Apply To Child Sites"
objExcel.Cells(1, 8).Value = "Enabled"
objExcel.Cells(1, 9).Value = "Rule ID"
Const adOpenStatic = 3
Const adLockOptimistic = 3
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=SQLOLEDB;Data Source =" & strServer & ";" & _
"Trusted_Connection=Yes;Initial Catalog =SMS_" & strDatabase
Set objRecordSet = CreateObject("ADODB.Recordset")
objRecordSet.Open _
" Select ProductName, OriginalFileName, FileName, FileVersion, " & _
" LanguageID, SiteCode, ApplyToChildSites, Enabled, RuleID " & _
" From v_MeteredProductRule" _
, objConnection, adOpenStatic, adLockOptimistic
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
objExcel.Cells(intRow, 1).Value = objRecordSet.Fields("ProductName").Value
objExcel.Cells(intRow, 2).Value = objRecordSet.Fields("OriginalFileName").Value
objExcel.Cells(intRow, 3).Value = objRecordSet.Fields("FileName").Value
objExcel.Cells(intRow, 4).Value = objRecordSet.Fields("FileVersion").Value
objExcel.Cells(intRow, 5).Value = objRecordSet.Fields("LanguageID").Value
objExcel.Cells(intRow, 6).Value = objRecordSet.Fields("SiteCode").Value
objExcel.Cells(intRow, 7).Value = objRecordSet.Fields("ApplyToChildSites").Value
objExcel.Cells(intRow, 8).Value = objRecordSet.Fields("Enabled").Value
objExcel.Cells(intRow, 9).Value = objRecordSet.Fields("RuleID").Value
objRecordSet.MoveNext
intRow = intRow + 1
Loop
objExcel.Range("A1:I1").Select
objExcel.Selection.Font.ColorIndex = 11
objExcel.Selection.Font.Bold = True
objExcel.Cells.EntireColumn.AutoFit
Set objSheet = objExcel.ActiveWorkbook.Worksheets(1)
Set objRange = objExcel.Range("A1")
objRange.Sort objRange,1,,,,,,1
MsgBox "Done"
VBS Script To Enumerate Only Enabled Software Metering Properties
" From v_MeteredProductRule Where Enabled = 1 " _
No Comments