Skip to content

Commit

Permalink
Update mk_inventory.vbs to include UBR in Windows OS version
Browse files Browse the repository at this point in the history
Retrieve minor windows version, this is useful to quickly know patchlevel among hosts.

See: https://ideas.checkmk.com/suggestions/484201/windows-mk_inventoryvbs-add-ubr-to-kernel-version
  • Loading branch information
gabrielgbs97 authored Aug 9, 2024
1 parent 892df77 commit 7620d7e
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions agents/windows/plugins/mk_inventory.vbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ End If

Const CMK_VERSION = "2.4.0b1"
CONST HKLM = &H80000002
Set rego = GetObject("WinMgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")

Dim delay
Dim exePaths
Expand Down Expand Up @@ -121,6 +122,31 @@ Sub getWMIObject2(strClass,arrVars)
Next
End Sub

Sub getOSDetails(arrVars)
Set Entries = objClass.ExecQuery("Select * from Win32_OperatingSystem")
Dim dwValue
strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion"
strValueName = "UBR"
intUBRErrCode = rego.GetDWORDValue(HKLM, strKeyPath, strValueName, dwValue)
For Each entry in Entries
strTemp = "A"
For Each label in arrVars
strTemp = strTemp & "|"
For Each item in entry.Properties_
If LCase(item.name) = LCase(label) Then
strTemp = strTemp & item.value
End If
Next
' Modify version field to include UBR
If LCase(label) = "version" and intUBRErrCode = 0 Then
strUBR = CStr(dwValue) ' Convert DWORD to str
strTemp = strTemp & "." & strUBR
End If
Next
outPut(Mid(strTemp,3))
Next
End Sub

Sub getNetworkAdapter(arrVars)
Set objClass = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set Entries = objClass.ExecQuery("Select * from Win32_NetworkAdapter")
Expand Down Expand Up @@ -276,7 +302,7 @@ Call getWMIObject("Win32_Processor",cpuVars)
' OS Version
Call startSection("win_os",124,timeUntil)
osVars = Array( "csname", "caption", "version", "OSArchitecture", "servicepackmajorversion", "ServicePackMinorVersion", "InstallDate" )
Call getWMIObject2("Win32_OperatingSystem",osVars)
Call getOSDetails(osVars)

' Memory
'Get-WmiObject Win32_PhysicalMemory -ComputerName $name | select BankLabel,DeviceLocator,Capacity,Manufacturer,PartNumber,SerialNumber,Speed
Expand Down Expand Up @@ -336,7 +362,6 @@ Loop

' Search Registry
Call startSection("win_reg_uninstall",124,timeUntil)
Set rego = GetObject("WinMgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
regVars = Array("DisplayName", "Publisher", "InstallLocation", "PSChildName", "DisplayVersion", "EstimatedSize", "InstallDate", "Language")

For Each path in regPaths
Expand Down

0 comments on commit 7620d7e

Please sign in to comment.