This VBS script will return the last Hardware Scan information for all the resources in a specified collection.
Note: Change the All Systems collection _Res_Coll_Sms00001 to any other collection needed.
VBS Script:
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 = "Machine Name"
objExcel.Cells(1, 2).Value = "Last HW Scan"
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 SD.Name0, WS.LastHWScan" & _
" From System_Disc SD" & _
" Join WorkstationStatus_Data WS On WS.MachineID = SD.ItemKey" & _
" Join _Res_Coll_Sms00001 RC On RC.MachineId = SD.ItemKey" _
, objConnection, adOpenStatic, adLockOptimistic
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
objExcel.Cells(intRow, 1).Value = objRecordSet.Fields("Name0").Value
objExcel.Cells(intRow, 2).Value = objRecordSet.Fields("LastHWScan").Value
objRecordSet.MoveNext
intRow = intRow + 1
Loop
objExcel.Range("A1:B1").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"
This VBS script will allow you to retrieve the machine names and their appropriate Network Operating Systems (NOS) names from Active Directory.
objExcel.Cells(1, 2).Value = "Network Operating System"
Const ADS_SCOPE_SUBTREE = 2
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOOBject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("DefaultNamingContext")
strBase = "<LDAP://" & strDNSDomain & ">"
strFilter = "(&(ObjectCategory=Computer))"
strAttributes = "Name, OperatingSystem, LastLogOff"
strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";SubTree"
objCommand.CommandText = strQuery
objCommand.Properties("Page Size") = 99999
objCommand.Properties("Timeout") = 300
objCommand.Properties("Cache Results") = False
Set objRecordSet = objCommand.Execute
objExcel.Cells(intRow, 1).Value = objRecordSet.Fields("Name").value
objExcel.Cells(intRow, 2).Value = objRecordset.Fields("OperatingSystem")
loop
objExcel.Selection.Interior.ColorIndex = 19
Msgbox "Done"
Provided here for your reference - and mine - is a list of the more common SMS log files with an easy to use description of each.
Client Component Installation Manager - Ccim
Client Configuration Manager - Ccm
Client Install Data Manager - Cidm
Collection Evaluator - Colleval
Component Status Summarizer - Compsumm
Courier Sender - Coursend
Courier Sender Confirmation - Cscnfsvc
Despooler - Despool
Discovery Data Manager - Ddm
Distribution Manager - Distmgr
Hardware Inventory Agent - Hinv
Hierarchy Manager - Hman
Hierarchy Manager - Sitecomp
Inbox Manager - Inboxmgr
Inbox Manager Assistant - Inboxast
Inventory Data Loader - Dataldr
Inventory Processor - Invproc
LAN Sender - Sender
License Metering - Licrsvc
License Server Manager - Licsvcfg
Network Discovery - Netdisc
Offer Manager - Offermgr
Offer Status Summarizer - Offersum
Replication Manager - Replmgr
Scheduler - Sched
Sender - Sender
Setup - SMSsetup
Site Component Manager - Sitecomp
Site Control Manager - Sitectrl
Site System Status Summarizer - Sitestat
SMS Administrator Provider - SMSprov
SMS Executive - SMSexec
SMS NT Logon Manager - NT_logon
SMS Provider - SMSprov
SMS SQL Monitor - SMSdbmon
SMS_Bootstrap Service - SMS_bootstrap
Software Inventory Agent - Sinv
Software Inventory Processor - Sinvproc
SQL Error Logs - Errorlog (Supports up yo .6)
Status Manager - Statmgr
Windows Networking Logon Discovery - NTlgdscm
Windows Networking Logon Installation - NTlginst
Windows NT Logon Discovery Agent - Ntlgdsca
Windows NT Logon Discovery Manager - Ntlgdscm
Windows NT Logon Server Manager - NT_logon
Windows NT Server Discovery Agent – Ntsvrdis
This By Request VBS script will provide you with an example of how to merge or use two disparate WMI classes in order to consolidate information contained within the two disconnected classes.
For example the WMI SMS_G_System_WorkStation_Status class contains the Resource ID rather than the resource NetBIOS or computer name and makes retrieving the information somewhat of a challenge to amalgamate. However if you tie the ResourceID to the ResourceID for the Computer name found in the SMS_R_System WMI class the information retrieved will be matched appropriately.
strComputer = InputBox ("Enter SMS Server Name")
strSiteCode = InputBox ("Enter Site Code")
objExcel.Cells(1, 2).Value = "Resource ID"
Set objWMIService = GetObject("winmgmts://" & strComputer & "\root\sms\site_" & strSiteCode)
Set colItems = objWMIService.ExecQuery("Select * from SMS_R_System")
For Each objItems in colItems
Set colItem = objWMIService.ExecQuery _
("Select * from SMS_G_System_WorkStation_Status")
For Each objItem in colItem
ResourceID = objItems.ResourceID
objExcel.Cells(intRow, 1).Value = objItems.Name
objExcel.Cells(intRow, 2).Value = ResourceID
Next
The VBS Script here will read a list of machines in a text file called MachineList and will provide you with the processor platform information for each resource.
VBS Script
objExcel.Cells(1, 2).Value = "Architecture"
Set Fso = CreateObject("Scripting.FileSystemObject")
Set InputFile = fso.OpenTextFile("MachineList.Txt")
Do While Not (InputFile.atEndOfStream)
strComputer = InputFile.ReadLine
On Error Resume Next
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Processor")
For Each objItem in colItems
objExcel.Cells(intRow, 1).Value = UCase(strComputer)
If Err.Number <> 0 Then
objExcel.Cells(intRow, 2).Value = Err.Description
Else
objExcel.Cells(intRow, 2).Value = objItem.Architecture
If objExcel.Cells(intRow, 2).Value = 0 Then
objExcel.Cells(intRow, 2).Value = "x86"
ElseIf objExcel.Cells(intRow, 2).Value = 1 Then
objExcel.Cells(intRow, 2).Value = "MIPS"
ElseIf objExcel.Cells(intRow, 2).Value = 2 Then
objExcel.Cells(intRow, 2).Value = "Alpha"
ElseIf objExcel.Cells(intRow, 2).Value = 3 Then
objExcel.Cells(intRow, 2).Value = "PowerPC"
ElseIf objExcel.Cells(intRow, 2).Value = 6 Then
objExcel.Cells(intRow, 2).Value = "Intel Itanium Processor Family (IPF)"
ElseIf objExcel.Cells(intRow, 2).Value = 9 Then
objExcel.Cells(intRow, 2).Value = "x64"
End If
This By Request VBS Script is in response to an email request where I was asked the following: “I have a VB script to open my CD drive but I have to close it myself. Can you tell me what the command to close it is. All I can find is the eject command.”
Set objCdDrive = CreateObject("WMPlayer.OCX.7")
Set colCDROM = objCdDrive.cdromCollection
If colCDROM.Count >= 1 then
For i = 0 to colCDROM.Count - 1
colCDROM.Item(i).Eject
My reply was just loop it using and additional Next and I sent him back the script below.
Note: If the Drive door is already opened when you run this VBS script it will just close the door. On laptops the mechanics may not be the same as desktops and the drive door will only open since it cannot be pulled back in.
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
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"
" Select ProductName, OriginalFileName, FileName, FileVersion, " & _
" LanguageID, SiteCode, ApplyToChildSites, Enabled, RuleID " & _
" From v_MeteredProductRule" _
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
objExcel.Range("A1:I1").Select
VBS Script To Enumerate Only Enabled Software Metering Properties
" From v_MeteredProductRule Where Enabled = 1 " _