운영 체제 속성 검색
Microsoft.SystemCenter.DiscoverWindowsOSProperties (Discovery)
운영 체제 클래스에 대한 속성을 검색합니다.
Element properties: Object Discovery Details: Member Modules:
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"/>
<Property PropertyID="PhysicalMemory"/>
</DiscoveryClass>
</DiscoveryTypes>
<DataSource ID="DiscoveryDataSource" TypeID="Windows!Microsoft.Windows.TimedPowerShell.DiscoveryProvider">
<IntervalSeconds>86400</IntervalSeconds>
<SyncTime/>
<ScriptName>DiscoverWindowsOSProperties.ps1</ScriptName>
<ScriptBody><Script>
Param($SourceType, $SourceId, $ManagedEntityId, $ComputerIdentity, $NetworkName)
#OS version for Win 2012
$WIN_OS_2012_Ver = "6.2"
$OSRegistryKey = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\"
#******************************************************************************
# FUNCTION: CheckMinOSVer
# DESCRIPTION: Returns True if the Registry Key for CurrentVersion
# is equal or Higher than the Minimum OS Versions Number.
# PARAMETER: DblMinVer Minimum Version Number to use
# RETURNS: Boolean: True, if build is greater or equal than the given number
#******************************************************************************
function CheckByOSCurrentVersion() #As Boolean
{
$strCurrentOSVer = Get-ItemProperty $OSRegistryKey
$strCurrentOSVer = $strCurrentOSVer.CurrentVersion
if($strCurrentOSVer -ge $WIN_OS_2012_Ver)
{
return $true;
}
return $false;
}
$api = new-object -comObject "MOM.ScriptAPI"
$properties = "Version","Caption","BuildNumber","CSDVersion","ServicePackMajorVersion","ServicePackMinorVersion","SerialNumber","InstallDate","WindowsDirectory","TotalVisibleMemorySize"
$isHigherThanWin08 = CheckByOSCurrentVersion
if($isHigherThanWin08 -eq $true)
{
Load-CimModules
try{
$cimSessionOption = New-CimSessionOption -Protocol DCOM
$cimsession = New-CimSession -ComputerName $NetworkName -SessionOption $cimSessionOption
$items = Get-CimInstance -CimSession $cimsession -Namespace "root\cimv2" -Class "Win32_OperatingSystem" -Property $properties -ErrorAction Stop
}
catch
{
$items = Get-WMIObject -Namespace "root\cimv2" -Class "Win32_OperatingSystem" -ComputerName $NetworkName -Property $properties -ErrorAction Stop
}
Finally{
Get-CimSession | Remove-CimSession
$cimsession =$null
$cimSessionOption = $null
}
}
else
{
$items = Get-WMIObject -Namespace "root\cimv2" -Class "Win32_OperatingSystem" -ComputerName $NetworkName -Property $properties
}
if($items -ne $null)
{
$discoveryData = $api.CreateDiscoveryData(0, $SourceId, $ManagedEntityId)
$windowsOS = $discoveryData.CreateClassInstance("$MPElement[Name='Windows!Microsoft.Windows.OperatingSystem']$")
$windowsOS.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", $ComputerIdentity)
foreach ($item in $items)
{
if($item -ne $null)
{
if($item.Version -ne $null)
{
$windowsOS.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.OperatingSystem']/OSVersion$", $item.Version)
}
else
{
$windowsOS.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.OperatingSystem']/OSVersion$", "")
}
if($item.Caption -ne $null)
{
$windowsOS.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.OperatingSystem']/OSVersionDisplayName$", $item.Caption)
$windowsOS.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $item.Caption)
}
else
{
$windowsOS.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.OperatingSystem']/OSVersionDisplayName$", "")
$windowsOS.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "")
}
if($item.BuildNumber -ne $null)
{
$windowsOS.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.OperatingSystem']/BuildNumber$", $item.BuildNumber)
}
else
{
$windowsOS.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.OperatingSystem']/BuildNumber$", "")
}
if($item.CSDVersion -ne $null)
{
$windowsOS.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.OperatingSystem']/CSDVersion$", $item.CSDVersion)
}
else
{
$windowsOS.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.OperatingSystem']/CSDVersion$", "")
}
if($item.ServicePackMajorVersion -ne $null)
{
$windowsOS.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.OperatingSystem']/ServicePackVersion$", $($item.ServicePackMajorVersion.ToString() + "." + $item.ServicePackMinorVersion.ToString()))
}
else
{
$windowsOS.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.OperatingSystem']/ServicePackVersion$", "")
}
if($item.SerialNumber -ne $null)
{
$windowsOS.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.OperatingSystem']/SerialNumber$", $item.SerialNumber)
}
else
{
$windowsOS.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.OperatingSystem']/SerialNumber$", "")
}
if($item.InstallDate -ne $null)
{
$dateTime = $item.InstallDate.ToString().Split(" ")
$windowsOS.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.OperatingSystem']/InstallDate$", $($dateTime[0] + " " + $dateTime[1]))
}
else
{
$windowsOS.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.OperatingSystem']/InstallDate$", "")
}
if($item.WindowsDirectory -ne $null)
{
$windowsOS.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.OperatingSystem']/SystemDrive$", $item.WindowsDirectory.substring(0,2))
$windowsOS.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.OperatingSystem']/WindowsDirectory$", $item.WindowsDirectory)
}
else
{
$windowsOS.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.OperatingSystem']/SystemDrive$", "")
$windowsOS.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.OperatingSystem']/WindowsDirectory$", "")
}
if($item.TotalVisibleMemorySize -ne $null)
{
$windowsOS.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.OperatingSystem']/PhysicalMemory$", $item.TotalVisibleMemorySize)
}
else
{
$windowsOS.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.OperatingSystem']/PhysicalMemory$", "")
}
}
}
$discoveryData.AddInstance($windowsOS)
$discoveryData
}
Function Load-CimModules
{
$error.Clear()
$CimModule = Get-Module CimCmdlets
if ($null -eq $CimModule)
{
Import-Module CimCmdlets
$error.Clear()
}
}
</Script> </ScriptBody>
<Parameters>
<Parameter>
<Name>SourceType</Name>
<Value>0</Value>
</Parameter>
<Parameter>
<Name>SourceId</Name>
<Value>$MPElement$</Value>
</Parameter>
<Parameter>
<Name>ManagedEntityId</Name>
<Value>$Target/Id$</Value>
</Parameter>
<Parameter>
<Name>ComputerIdentity</Name>
<Value>$Target/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName$</Value>
</Parameter>
<Parameter>
<Name>NetworkName</Name>
<Value>$Target/Property[Type="Windows!Microsoft.Windows.Computer"]/NetworkName$</Value>
</Parameter>
</Parameters>
<TimeoutSeconds>300</TimeoutSeconds>
</DataSource>
</Discovery>