set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & NetworkName & "\root\cimv2")
set items = objWMIService.ExecQuery("SELECT Version,Caption,BuildNumber,CSDVersion,ServicePackMajorVersion,ServicePackMinorVersion,SerialNumber,InstallDate,WindowsDirectory,TotalVisibleMemorySize FROM Win32_OperatingSystem")
If IsNull(items) = false And items.Count > 0 Then
Dim oDiscoveryData, oWindowsOS
set oDiscoveryData = oAPI.CreateDiscoveryData(0, SourceId, ManagedEntityId)
set oWindowsOS = oDiscoveryData.CreateClassInstance("$MPElement[Name='Windows!Microsoft.Windows.OperatingSystem']$")
For Each item in items
If IsNull(item) = False Then
if IsNull(item.Version) = false then
call oWindowsOS.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.OperatingSystem']/OSVersion$", item.Version)
else
call oWindowsOS.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.OperatingSystem']/OSVersion$", "")
end if
if IsNull(item.Caption) = false then
call oWindowsOS.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.OperatingSystem']/OSVersionDisplayName$", item.Caption)
call oWindowsOS.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", item.Caption)
else
call oWindowsOS.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.OperatingSystem']/OSVersionDisplayName$", "")
call oWindowsOS.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "")
end if
if IsNull(item.BuildNumber) = false then
call oWindowsOS.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.OperatingSystem']/BuildNumber$", item.BuildNumber)
else
call oWindowsOS.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.OperatingSystem']/BuildNumber$", "")
end if
if IsNull(item.CSDVersion) = false then
call oWindowsOS.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.OperatingSystem']/CSDVersion$", item.CSDVersion)
else
call oWindowsOS.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.OperatingSystem']/CSDVersion$", "")
end if
if IsNull(item.ServicePackMajorVersion) = false and IsNull(item.ServicePackMinorVersion) = false then
call oWindowsOS.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.OperatingSystem']/ServicePackVersion$", item.ServicePackMajorVersion & "." & item.ServicePackMinorVersion)
else
call oWindowsOS.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.OperatingSystem']/ServicePackVersion$", "")
end if
if IsNull(item.SerialNumber) = false then
call oWindowsOS.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.OperatingSystem']/SerialNumber$", item.SerialNumber)
else
call oWindowsOS.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.OperatingSystem']/SerialNumber$", "")
end if
if IsNull(item.InstallDate) = false then
datetime = GetDateTime(item.InstallDate)
call oWindowsOS.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.OperatingSystem']/InstallDate$", datetime)
else
call oWindowsOS.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.OperatingSystem']/InstallDate$", "")
end if
if IsNull(item.WindowsDirectory) = false then
call oWindowsOS.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.OperatingSystem']/SystemDrive$", Left(item.WindowsDirectory, 2))
call oWindowsOS.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.OperatingSystem']/WindowsDirectory$", item.WindowsDirectory)
else
call oWindowsOS.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.OperatingSystem']/SystemDrive$", "")
call oWindowsOS.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.OperatingSystem']/WindowsDirectory$", "")
end if
if IsNull(item.TotalVisibleMemorySize) = false then
call oWindowsOS.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.OperatingSystem']/PhysicalMemory$", item.TotalVisibleMemorySize)
else
call oWindowsOS.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.OperatingSystem']/PhysicalMemory$", "")
end if
Function GetDateTime(datetime)
GetDateTime = FormatDateTime(DateValue(mid(datetime, 5, 2) & "/" & mid(datetime, 7, 2) & "/" & left(datetime, 4))) & " " & mid(datetime, 9, 2) & ":" & mid(datetime, 11, 2) & ":" & mid(datetime, 13, 2)
End Function </Script></ScriptBody>
<TimeoutSeconds>300</TimeoutSeconds>
</DataSource>
</Discovery>