Discovery Operating System Properties

Microsoft.SystemCenter.DiscoverWindowsOSProperties (Discovery)

Discover properties on the Operating System type.

Element properties:

TargetMicrosoft.Windows.Computer
EnabledTrue
Frequency86400
RemotableFalse
CommentDiscover OS properties using WMI

Object Discovery Details:

Discovered Classes and their attribuets:
  • Microsoft.Windows.OperatingSystem
    • DisplayName
    • OSVersion
    • OSVersionDisplayName
    • BuildNumber
    • CSDVersion
    • ServicePackVersion
    • SerialNumber
    • InstallDate
    • SystemDrive
    • WindowsDirectory

Member Modules:

ID Module Type TypeId RunAs 
DiscoveryDataSource DataSource Microsoft.Windows.TimedScript.DiscoveryProvider Default

Source Code:

<Discovery ID="Microsoft.SystemCenter.DiscoverWindowsOSProperties" Comment="Discover OS properties using WMI" Enabled="true" Target="Windows!Microsoft.Windows.Computer" ConfirmDelivery="false" Remotable="true" Priority="Normal">
<Category>Discovery</Category>
<DiscoveryTypes>
<DiscoveryClass TypeID="Windows!Microsoft.Windows.OperatingSystem">
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
<Property PropertyID="OSVersion"/>
<Property PropertyID="OSVersionDisplayName"/>
<Property PropertyID="BuildNumber"/>
<Property PropertyID="CSDVersion"/>
<Property PropertyID="ServicePackVersion"/>
<Property PropertyID="SerialNumber"/>
<Property PropertyID="InstallDate"/>
<Property PropertyID="SystemDrive"/>
<Property PropertyID="WindowsDirectory"/>
</DiscoveryClass>
</DiscoveryTypes>
<DataSource ID="DiscoveryDataSource" TypeID="Windows!Microsoft.Windows.TimedScript.DiscoveryProvider">
<IntervalSeconds>86400</IntervalSeconds>
<SyncTime/>
<ScriptName>DiscoverWindowsOSProperties.vbs</ScriptName>
<Arguments>0 $MPElement$ $Target/Id$ $Target/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName$ $Target/Property[Type="Windows!Microsoft.Windows.Computer"]/NetworkName$</Arguments>
<ScriptBody><Script>
Dim oAPI
Dim oShell
Dim oArgs
Dim objWMIService
Dim items

set oAPI = CreateObject("MOM.ScriptAPI")
set oShell = CreateObject("WScript.Shell")
set oArgs = WScript.Arguments

SourceType = oArgs(0)
SourceId = oArgs(1)
ManagedEntityId = oArgs(2)
ComputerIdentity = oArgs(3)
NetworkName = oArgs(4)

set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &amp; NetworkName &amp; "\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 &gt; 0 Then
Dim oDiscoveryData, oWindowsOS

set oDiscoveryData = oAPI.CreateDiscoveryData(0, SourceId, ManagedEntityId)
set oWindowsOS = oDiscoveryData.CreateClassInstance("$MPElement[Name='Windows!Microsoft.Windows.OperatingSystem']$")

call oWindowsOS.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", ComputerIdentity)

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 &amp; "." &amp; 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

Exit For
End If
Next

oDiscoveryData.AddInstance(oWindowsOS)
oAPI.Return(oDiscoveryData)

end if

Function GetDateTime(datetime)
GetDateTime = FormatDateTime(DateValue(mid(datetime, 5, 2) &amp; "/" &amp; mid(datetime, 7, 2) &amp; "/" &amp; left(datetime, 4))) &amp; " " &amp; mid(datetime, 9, 2) &amp; ":" &amp; mid(datetime, 11, 2) &amp; ":" &amp; mid(datetime, 13, 2)
End Function
</Script></ScriptBody>
<TimeoutSeconds>300</TimeoutSeconds>
</DataSource>
</Discovery>