Lenovo Baseboard Management Controller 发现
Lenovo.HardwareMgmtPack.IMM2.ManagementModule.Discover (DataSourceModuleType)
Element properties:
Member Modules:
Overrideable Parameters:
Source Code:
<DataSourceModuleType ID="Lenovo.HardwareMgmtPack.IMM2.ManagementModule.Discover" Accessibility="Public">
<Configuration>
<IncludeSchemaTypes>
<SchemaType>System!System.ExpressionEvaluatorSchema</SchemaType>
</IncludeSchemaTypes>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="IntervalSeconds" type="xsd:int"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="SyncTime" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="TimeoutSeconds" type="xsd:int"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="Expression" type="ExpressionType"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int"/>
<OverrideableParameter ID="TimeoutSeconds" Selector="$Config/TimeoutSeconds$" ParameterType="int"/>
</OverrideableParameters>
<ModuleImplementation>
<Composite>
<MemberModules>
<DataSource ID="DS" TypeID="System!System.Discovery.Scheduler">
<Scheduler>
<SimpleReccuringSchedule>
<Interval>$Config/IntervalSeconds$</Interval>
<SyncTime>$Config/SyncTime$</SyncTime>
</SimpleReccuringSchedule>
<ExcludeDates/>
</Scheduler>
</DataSource>
<ProbeAction ID="PSScript" TypeID="Windows!Microsoft.Windows.PowerShellDiscoveryProbe">
<ScriptName>Lenovo.IMMDiscovery.ps1</ScriptName>
<ScriptBody><Script>
param($sourceId,$managedEntityId)
function Get-RegistryValue($key, $value)
{
(Get-ItemProperty $key $value).$value
}
function WriteLog($str, $RegDebug, $debugLevel)
{
if ($RegDebug -gt $debugLevel)
{
#Write-Host $str
#$str | Out-File -FilePath "c:\immdisc.log.txt" -Encoding ascii -Append
if ([System.Diagnostics.EventLog]::SourceExists("Lenovo.EventLogSource") -eq $false)
{
[System.Diagnostics.EventLog]::CreateEventSource("Lenovo.EventLogSource", "Operations Manager")
}
if ($str -eq $null)
{
$str = "null"
}
Write-EventLog -LogName 'Operations Manager' -Source 'Lenovo.EventLogSource' -EventId 3002 -EntryType Information -Message $str
}
}
$RegDebug = Get-RegistryValue 'HKLM:\SOFTWARE\Lenovo\Lenovo SCOM MP\Debug' 'Level'
if($RegDebug -eq $null)
{
$RegDebug = '0'
}
$RegDebug = [Convert]::ToInt32($RegDebug,10)
$logstring = "RegDebug = " + $RegDebug
WriteLog $logstring $RegDebug 5
$paramStr='sourceId={0},managedEntityId={1}' -f $sourceId,$managedEntityId
WriteLog $paramStr $RegDebug 5
# multitool language support for 'Supported','Not supported','Passed','Failed'. if those strings can be got translated, using below code to support their localization.
$langPool = @{
'en-US' = @{
'Supported' = 'Supported';
'Not supported' = 'Not supported';
'Passed' = 'Passed';
'Failed' = 'Failed';
};
'zh-TW' = @{
'Supported' = '支援';
'Not supported' = '不支援';
'Passed' = '通過';
'Failed' = '失敗';
};
'de-DE' = @{
'Supported' = 'Unterstützt';
'Not supported' = 'Nicht unterstützt';
'Passed' = 'Bestanden';
'Failed' = 'Fehler';
};
'es-ES' = @{
'Supported' = 'Compatible';
'Not supported' = 'No soportado';
'Passed' = 'Correcto';
'Failed' = 'Error';
};
'fr-FR' = @{
'Supported' = 'Pris en charge';
'Not supported' = 'Non pris en charge';
'Passed' = 'Réussite';
'Failed' = 'Echec';
};
'it-IT' = @{
'Supported' = 'Supportato';
'Not supported' = 'Non supportato';
'Passed' = 'Riuscito';
'Failed' = 'Non riuscito';
};
'ja-JP' = @{
'Supported' = 'サポート対象';
'Not supported' = 'サポート対象外';
'Passed' = '合格';
'Failed' = '不合格';
};
'ko-KR' = @{
'Supported' = '지원됨';
'Not supported' = '지원되지 않음';
'Passed' = '통과됨';
'Failed' = '실패';
};
'pt-BR' = @{
'Supported' = 'Suportados';
'Not supported' = 'Não suportada';
'Passed' = 'Aprovado';
'Failed' = 'Falhou';
};
'ru-RU' = @{
'Supported' = 'Поддерживается';
'Not supported' = 'Не поддерживается';
'Passed' = 'Выполнено';
'Failed' = 'Отказ';
};
'zh-CN' = @{
'Supported' = '受支持';
'Not supported' = '不受支持';
'Passed' = '已通过';
'Failed' = '失败';
};
};
$OSLanguage = ((Get-WmiObject -Class Win32_OperatingSystem -Namespace root/cimv2).MUILanguages)[-1]
if(!$langPool.Contains("$OSLanguage"))
{
$OSLanguage = "en-US"
}
$mri = $langPool["$OSLanguage"]
try{
$api = New-Object -comObject 'MOM.ScriptAPI'
$discoveryData = $api.CreateDiscoveryData(0, $sourceId, $managedEntityId)
WriteLog "Get BMC Info from DB" $RegDebug 5
try{
# by default, SecurityProtocol is sslv3 and tls
# add 768 (tls11) and 3072(tls12) for case if web server only supports tls11 or tls12 protocol
# not use [System.Net.SecurityProtocolType]::Tls11/Tls12 directly because it only exists in .Net 4.5 or later
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 768 -bor 3072
}catch{}
$protocol = [System.Net.ServicePointManager]::SecurityProtocol
$logstring = "SupportSecurityProtocol: " + $protocol
WriteLog $logstring $RegDebug 5
$hwmp_path = Get-RegistryValue 'HKLM:\SOFTWARE\Lenovo\Systems Management Integrations\Lenovo HW Mgmt Pack for OpsMgr' 'Path'
$dllname = $hwmp_path + '\ScomAuthentication.dll'
[void][reflection.assembly]::LoadFile($dllname)
$dll_func = New-Object ScomAuthentication.ScomAuth
$token = $dll_func.GetToken()
$service_port = Get-RegistryValue 'HKLM:\SOFTWARE\Wow6432Node\Lenovo\UnifiedService' 'Port'
if($service_port -eq $null)
{
$service_port = Get-RegistryValue 'HKLM:\SOFTWARE\Wow6432Node\Lenovo.\UnifiedService' 'Port'
}
$logstring = "service_port= " + $service_port
WriteLog $logstring $RegDebug 5
#invoke webrequest to exchange with server and get cookie info
$url = "https://localhost:" + $service_port + "/session/?operation=exchange&token=" + $token
Invoke-WebRequest -Uri $url -UseBasicParsing -SessionVariable fb | ConvertFrom-Json
$csk = $fb.Cookies[0].GetCookies("https://localhost:"+ $service_port)
$fb.Headers.Add("x-csrf-token",$csk[1].Value)
$page = 0
$page_size = 10
do
{
$page = $page +1
$logstring = "Get " + $page + " page , evey page contains " + $page_size +" info"
WriteLog $logstring $RegDebug 5
add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {
return true;
}
}
"@
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
#invoke webrequest with cookie to get server info
$url = "https://localhost:" + $service_port + "/endpoints/?operation=show_all&exclude_type=ThinkServer&page=" + $page+ "&page_size=" + $page_size
$immresponse = Invoke-WebRequest -Uri $url -UseBasicParsing -WebSession $fb | ConvertFrom-Json
if($immresponse.return_data -eq ""){
return true;
}
$immlist = $immresponse.return_data.endpoints
$next_page = $immresponse.return_data.next_page
$imm_count = $immresponse.return_data.returned_number
WriteLog $imm_count $RegDebug 5
$count = 0
foreach ($item in $immlist)
{
try{
WriteLog "enter one imm" $RegDebug 5
if($count -lt $imm_count)
{
$count++;
WriteLog $count $RegDebug 5
WriteLog $item $RegDebug 5
}
else
{
WriteLog $item $RegDebug 5
WriteLog "break" $RegDebug 5
break;
}
$status_Auth = "Failed"
$status_RAS = "Supported"
$status_Auth = $mri["Failed"]
$status_RAS = $mri["Supported"]
$item_Fan = $item.Fan
$item_NumericSensor = $item.NumericSensor
$item_PhysicalMemory = $item.PhysicalMemory
$item_Processor = $item.Processor
$item_SoftwareIndentity = $item.SoftwareIndentity
$item_Disk = $item.Disk
$item_IMM = $item.IMM[0]
$item_RAS = $item.RecordLog
$item_OShost = $item.oshost
$item_RAID = $item.RAID
$item_PCI = $item.Pci
$item_NIC = $item.Nic
$imm_HostName = $item_IMM.hostname
$OS_HostName = $item_OShost.inbound_computername
$imm_IP = $item_IMM.ipaddress
if ($imm_HostName)
{
$imm_HostName = $imm_HostName.Trim()
}
if ($OS_HostName)
{
$OS_HostName = $OS_HostName.Trim()
}
if ($imm_IP)
{
$imm_IP = $imm_IP.Trim()
}
$imm_DisplayName = $OS_HostName
Write-Host $item_IMM.uuid
if(($item_IMM.password -ne "") -and $item_IMM.account_verified )
{
$status_Auth = "Passed"
$status_Auth = $mri["Passed"]
}
if(($item_RAS.supported_categories % 2) -eq 0 )
{
$status_RAS = "Not supported"
$status_RAS = $mri["Not supported"]
}
#********************************************************************
#create BMC instance
#********************************************************************
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.ManagementModule']$")
if ($OS_HostName)
{
$imm_DisplayName = $OS_HostName
}
elseif ($imm_HostName)
{
$imm_DisplayName = $imm_HostName
}
elseif ($imm_IP)
{
$imm_DisplayName = $imm_IP
}
else
{
$imm_DisplayName = $item_IMM.uuid
}
$instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$",$imm_DisplayName)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.ManagementModule']/UUID$", $item_IMM.uuid)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.ManagementModule']/Manufacturer$", $item_IMM.manufacturer)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.ManagementModule']/Model$", $item_IMM.model)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.ManagementModule']/PartNumber$", $item_IMM.partnumber)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.ManagementModule']/SerialNumber$", $item_IMM.serialnumber)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.ManagementModule']/NumberOfReboots$", $item_IMM.number_of_reboots)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.ManagementModule']/IMMLastDicoveryDate$", $item_IMM.imm_last_discovery_date)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.ManagementModule']/IMMIP$", $item_IMM.ipaddress)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.ManagementModule']/IMMConnectionStatus$",$status_Auth)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.ManagementModule']/InbandComputerName$",$item_OShost.inbound_computername)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.ManagementModule']/IMMHostName$",$item_IMM.hostname)
$discoveryData.AddInstance($instance)
#********************************************************************
#create RAID instance
#********************************************************************
foreach ($item in $item_RAID)
{
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.RAID']$")
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.BaseSubModule']/IMMIP$",$item_IMM.ipaddress)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.BaseSubModule']/IMMHostName$",$item_IMM.hostname)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.BaseSubModule']/UUID$",$item_IMM.uuid)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.BaseSubModule']/InbandComputerName$",$item_OShost.inbound_computername)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.RAID']/UniqueId$",$imm_DisplayName+"_"+$item.Name)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.RAID']/Model$",$item.Model)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.RAID']/Manufacturer$",$item.Manufacturer)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.RAID']/SerialNumber$",$item.SerialNumber)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.RAID']/PartNumber$",$item.PartNumber)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.RAID']/Firmware$",$item.VersionString)
$PhyDriveDisp = ""
foreach ($phydrive in $item.PhysicalDrive)
{
$PhyDriveDisp = $PhyDriveDisp + "ElementName: " + $phydrive.ElementName
$PhyDriveDisp = $PhyDriveDisp + "; DefaultBlockSize: " + $phydrive.DefaultBlockSize
$PhyDriveDisp = $PhyDriveDisp + "; MaxMediaSize: " + $phydrive.MaxMediaSize
$PhyDriveDisp = $PhyDriveDisp + ";"
}
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.RAID']/PhyDrive$",$PhyDriveDisp)
$LogDriveDisp = ""
foreach ($logdrive in $item.LogicalDrive)
{
$LogDriveDisp = $LogDriveDisp + "PoolID: " + $logdrive.PoolID
$LogDriveDisp = $LogDriveDisp + "; RAIDLevel: " + $logdrive.RAIDLevel
$LogDriveDisp = $LogDriveDisp + "; TotalManagedSpace: " + $logdrive.TotalManagedSpace
$LogDriveDisp = $LogDriveDisp + "; Logical Volume { "
foreach ($logvolume in $logdrive.LogicalVolume)
{
$LogDriveDisp = $LogDriveDisp + "VolumeID: " + $logvolume.VolumeID
$LogDriveDisp = $LogDriveDisp + "; Bootable: " + $logvolume.Bootable
$LogDriveDisp = $LogDriveDisp + "; BlockSize: " + $logvolume.BlockSize
$LogDriveDisp = $LogDriveDisp + "; BlockNum: " + $logvolume.BlockNum
$LogDriveDisp = $LogDriveDisp + "; "
}
$LogDriveDisp = $LogDriveDisp + "}; "
}
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.RAID']/LogDrive$",$LogDriveDisp)
$BatteryDisp = ""
foreach ($battery in $item.Battery)
{
$BatteryDisp = $BatteryDisp + "SerialNO: " + $battery.SerialNO
$BatteryDisp = $BatteryDisp + "; Chemistry: " + $battery.Chemistry
$BatteryDisp = $BatteryDisp + "; RemainingCap: " + $battery.RemainingCap
$BatteryDisp = $BatteryDisp + "; FullChargeCap: " + $battery.FullChargeCap
$BatteryDisp = $BatteryDisp + "; DesignCap: " + $battery.DesignCap
$BatteryDisp = $BatteryDisp + "; "
}
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.RAID']/Battery$",$BatteryDisp)
$discoveryData.AddInstance($instance)
}
#********************************************************************
#create PCI instance
#********************************************************************
foreach ($item in $item_PCI)
{
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.PCI']$")
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.BaseSubModule']/IMMIP$",$item_IMM.ipaddress)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.BaseSubModule']/IMMHostName$",$item_IMM.hostname)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.BaseSubModule']/UUID$",$item_IMM.uuid)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.BaseSubModule']/InbandComputerName$",$item_OShost.inbound_computername)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.PCI']/UniqueId$",$imm_DisplayName+"_"+$item.Name+"_"+$item.Model)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.PCI']/Model$",$item.Model)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.PCI']/Manufacturer$",$item.Manufacturer)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.PCI']/SerialNumber$",$item.SerialNumber)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.PCI']/PartNumber$",$item.PartNumber)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.PCI']/BusNumber$",$item.BusNumber)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.PCI']/DeviceNumber$",$item.DeviceNumber)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.PCI']/Slot$",$item.Slot)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.PCI']/Firmware$",$item.VersionString)
$discoveryData.AddInstance($instance)
}
#********************************************************************
#create Ethernet and Port instance
#********************************************************************
foreach ($item in $item_NIC)
{
if($item.Type -eq 1)
{
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.FC']$")
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.BaseSubModule']/IMMIP$",$item_IMM.ipaddress)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.BaseSubModule']/IMMHostName$",$item_IMM.hostname)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.BaseSubModule']/UUID$",$item_IMM.uuid)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.BaseSubModule']/InbandComputerName$",$item_OShost.inbound_computername)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.NIC']/UniqueId$",$imm_DisplayName+"_"+$item.Name)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.NIC']/Model$",$item.Model)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.NIC']/Manufacturer$",$item.Manufacturer)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.NIC']/SerialNumber$",$item.SerialNumber)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.NIC']/PartNumber$",$item.PartNumber)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.NIC']/BusNumber$",$item.BusNumber)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.NIC']/DeviceNumber$",$item.DeviceNumber)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.NIC']/Slot$",$item.Slot)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.NIC']/Firmware$",$item.VersionString)
$PortDisp = ""
foreach ($port in $item.Port)
{
$PortDisp = $PortDisp + "Name: " + $port.Name
$PortDisp = $PortDisp + "; LinkTechnology: " + $port.LinkTechnology
$PortDisp = $PortDisp + "; PermanentAddress: " + $port.PermanentAddress
$PortDisp = $PortDisp + "; NetworkAddress: " + $port.NetworkAddress
$PortDisp = $PortDisp + "; Speed: " + $port.Speed
$PortDisp = $PortDisp + "; NIC Type: " + $port.NICType
$PortDisp = $PortDisp + "; "
}
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.NIC']/Port$",$portDisp)
}
elseif($item.Type -eq 2)
{
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.IB']$")
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.BaseSubModule']/IMMIP$",$item_IMM.ipaddress)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.BaseSubModule']/IMMHostName$",$item_IMM.hostname)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.BaseSubModule']/UUID$",$item_IMM.uuid)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.BaseSubModule']/InbandComputerName$",$item_OShost.inbound_computername)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.NIC']/UniqueId$",$imm_DisplayName+"_"+$item.Name)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.NIC']/Model$",$item.Model)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.NIC']/Manufacturer$",$item.Manufacturer)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.NIC']/SerialNumber$",$item.SerialNumber)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.NIC']/PartNumber$",$item.PartNumber)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.NIC']/BusNumber$",$item.BusNumber)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.NIC']/DeviceNumber$",$item.DeviceNumber)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.NIC']/Slot$",$item.Slot)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.NIC']/Firmware$",$item.VersionString)
$PortDisp = ""
foreach ($port in $item.Port)
{
$PortDisp = $PortDisp + "Name: " + $port.Name
$PortDisp = $PortDisp + "; LinkTechnology: " + $port.LinkTechnology
$PortDisp = $PortDisp + "; PermanentAddress: " + $port.PermanentAddress
$PortDisp = $PortDisp + "; NetworkAddress: " + $port.NetworkAddress
$PortDisp = $PortDisp + "; Speed: " + $port.Speed
$PortDisp = $PortDisp + "; NIC Type: " + $port.NICType
$PortDisp = $PortDisp + "; "
}
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.NIC']/Port$",$portDisp)
}
else
{
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.Ethernet']$")
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.BaseSubModule']/IMMIP$",$item_IMM.ipaddress)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.BaseSubModule']/IMMHostName$",$item_IMM.hostname)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.BaseSubModule']/UUID$",$item_IMM.uuid)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.BaseSubModule']/InbandComputerName$",$item_OShost.inbound_computername)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.NIC']/UniqueId$",$imm_DisplayName+"_"+$item.Name)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.NIC']/Model$",$item.Model)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.NIC']/Manufacturer$",$item.Manufacturer)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.NIC']/SerialNumber$",$item.SerialNumber)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.NIC']/PartNumber$",$item.PartNumber)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.NIC']/BusNumber$",$item.BusNumber)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.NIC']/DeviceNumber$",$item.DeviceNumber)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.NIC']/Slot$",$item.Slot)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.NIC']/Firmware$",$item.VersionString)
$PortDisp = ""
foreach ($port in $item.Port)
{
$PortDisp = $PortDisp + "Name: " + $port.Name
$PortDisp = $PortDisp + "; LinkTechnology: " + $port.LinkTechnology
$PortDisp = $PortDisp + "; PermanentAddress: " + $port.PermanentAddress
$PortDisp = $PortDisp + "; NetworkAddress: " + $port.NetworkAddress
$PortDisp = $PortDisp + "; Speed: " + $port.Speed
$PortDisp = $PortDisp + "; NIC Type: " + $port.NICType
$PortDisp = $PortDisp + "; "
}
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.NIC']/Port$",$portDisp)
}
$discoveryData.AddInstance($instance)
#********************************************************************
#create Port instance
#********************************************************************
foreach ($port in $item.Port)
{
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.Port']$")
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.BaseSubModule']/IMMIP$",$item_IMM.ipaddress)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.BaseSubModule']/IMMHostName$",$item_IMM.hostname)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.BaseSubModule']/UUID$",$item_IMM.uuid)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.BaseSubModule']/InbandComputerName$",$item_OShost.inbound_computername)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.Port']/UniqueId$",$imm_DisplayName+"_"+$item.Name+"_"+$item.Model)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.Port']/Name$",$port.Name)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.Port']/LinkTechnology$",$port.LinkTechnology)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.Port']/PermanentAddress$",$port.PermanentAddress)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.Port']/NetworkAddress$",$port.NetworkAddress)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.Port']/Speed$",$port.Speed)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.Port']/NICType$",$port.NICType)
$discoveryData.AddInstance($instance)
}
}
#********************************************************************
#create Fan instance
#********************************************************************
foreach($item in $item_Fan)
{
if ($item.Caption)
{
$id = "01"
try{
$idTmpList = $item.Caption -split " "
if ($idTmpList.count -gt 1)
{
$idTmp = [Convert]::ToInt32($idTmpList[1],10)
$id = "{0:D2}" -f $idTmp
}
}
catch{
WriteLog 'exception happened' $RegDebug 5
$msg=$error[0]
WriteLog $msg $RegDebug 5
}
}
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.Fan']$")
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.BaseSubModule']/IMMIP$",$item_IMM.ipaddress)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.BaseSubModule']/IMMHostName$",$item_IMM.hostname)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.BaseSubModule']/UUID$",$item_IMM.uuid)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.BaseSubModule']/InbandComputerName$",$item_OShost.inbound_computername)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.ManagementModule']/UUID$",$item_IMM.uuid)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.Fan']/UniqueId$",$imm_DisplayName+"_"+$item.Caption)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.Fan']/Caption$",$item.Caption)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.Fan']/Identifier$",$id)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.Fan']/Description$",$item.Description)
$discoveryData.AddInstance($instance)
}
#********************************************************************
#create NumericSensor instance
#********************************************************************
foreach($item in $item_NumericSensor)
{
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.NumericSensor']$")
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.BaseSubModule']/IMMIP$",$item_IMM.ipaddress)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.BaseSubModule']/IMMHostName$",$item_IMM.hostname)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.BaseSubModule']/UUID$",$item_IMM.uuid)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.BaseSubModule']/InbandComputerName$",$item_OShost.inbound_computername)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.NumericSensor']/UniqueId$",$imm_DisplayName+"_"+$item.ElementName)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.NumericSensor']/Caption$",$item.Caption)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.NumericSensor']/ElementName$",$item.ElementName)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.NumericSensor']/Description$",$item.Description)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.NumericSensor']/CurrentState$",$item.CurrentState)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.NumericSensor']/CurrentReading$",$item.CurrentReading)
$discoveryData.AddInstance($instance)
}
#********************************************************************
#create PhysicalMemory instance
#********************************************************************
foreach($item in $item_PhysicalMemory)
{
$Number = "1"
try{
$NumList = $item.BankLabel -split " "
if ($NumList.count -gt 1)
{
$NumTmp = [Convert]::ToInt32($NumList[1],10)
$Number = "{0:X2}" -f $NumTmp
}
}
catch{
WriteLog 'exception happened' $RegDebug 5
$msg=$error[0]
WriteLog $msg $RegDebug 5
}
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.PhysicalMemory']$")
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.BaseSubModule']/IMMIP$",$item_IMM.ipaddress)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.BaseSubModule']/IMMHostName$",$item_IMM.hostname)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.BaseSubModule']/UUID$",$item_IMM.uuid)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.BaseSubModule']/InbandComputerName$",$item_OShost.inbound_computername)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.ManagementModule']/UUID$",$item_IMM.uuid)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.PhysicalMemory']/UniqueId$",$imm_DisplayName+"_"+$Number+"_"+$item.Description)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.PhysicalMemory']/Capacity$",$item.Capacity)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.PhysicalMemory']/Identifier$",$Number)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.PhysicalMemory']/BankLabel$",$item.BankLabel)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.PhysicalMemory']/Description$",$item.Description)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.PhysicalMemory']/IsSpeedInMhz$",$item.IsSpeedInMhz)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.PhysicalMemory']/Manufacturer$",$item.Manufacturer)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.PhysicalMemory']/Model$",$item.Model)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.PhysicalMemory']/PartNumber$",$item.PartNumber)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.PhysicalMemory']/SerialNumber$",$item.SerialNumber)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.PhysicalMemory']/Speed$",$item.Speed)
$discoveryData.AddInstance($instance)
}
#********************************************************************
#create Processor instance
#********************************************************************
foreach($item in $item_Processor)
{
$CPUNumber = "1"
$uId = ""
try{
$CPUNumList = $item.Caption -split " "
if ($CPUNumList.count -gt 1)
{
$CPUNumTmp = [Convert]::ToInt32($CPUNumList[1],10)
$CPUNumber = "{0:X2}" -f $CPUNumTmp
}
$uId = $imm_DisplayName+"_"+$item.Caption
}
catch{
WriteLog 'exception happened' $RegDebug 5
$msg=$error[0]
WriteLog $msg $RegDebug 5
}
if ($uId -eq "")
{
$uId = $imm_DisplayName+"_"+$item.ElementName
}
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.Processor']$")
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.BaseSubModule']/IMMIP$",$item_IMM.ipaddress)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.BaseSubModule']/IMMHostName$",$item_IMM.hostname)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.BaseSubModule']/UUID$",$item_IMM.uuid)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.BaseSubModule']/InbandComputerName$",$item_OShost.inbound_computername)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.ManagementModule']/UUID$",$item_IMM.uuid)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.Processor']/Caption$",$item.Caption)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.Processor']/Identifier$",$CPUNumber)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.Processor']/UniqueId$",$uId)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.Processor']/CPUStatus$",$item.CPUStatus)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.Processor']/CurrentClockSpeed$",$item.CurrentClockSpeed)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.Processor']/Name$",$item.Name)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.Processor']/ExternalBusClockSpeed$",$item.ExternalBusClockSpeed)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.Processor']/Family$",$item.Family)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.Processor']/MaxClockSpeed$",$item.MaxClockSpeed)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.Processor']/NumberOfEnabledCores$",$item.NumberOfEnabledCores)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.Processor']/OtherFamilyDescription$",$item.OtherFamilyDescription)
$discoveryData.AddInstance($instance)
}
#********************************************************************
#create SoftwareIndentity instance
#********************************************************************
foreach($item in $item_SoftwareIndentity)
{
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.SoftwareIndentity']$")
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.BaseSubModule']/IMMIP$",$item_IMM.ipaddress)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.BaseSubModule']/IMMHostName$",$item_IMM.hostname)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.BaseSubModule']/UUID$",$item_IMM.uuid)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.BaseSubModule']/InbandComputerName$",$item_OShost.inbound_computername)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.SoftwareIndentity']/UniqueId$",$imm_DisplayName+"_"+$item.ElementName)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.SoftwareIndentity']/ElementName$",$item.ElementName)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.SoftwareIndentity']/IdentityInfoType$",$item.IdentityInfoType)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.SoftwareIndentity']/IdentityInfoValue$",$item.IdentityInfoValue)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.SoftwareIndentity']/MajorVersion$",$item.MajorVersion)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.SoftwareIndentity']/MinorVersion$",$item.MinorVersion)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.SoftwareIndentity']/VersionString$",$item.VersionString)
$discoveryData.AddInstance($instance)
}
#********************************************************************
#create Disk instance
#********************************************************************
foreach($item in $item_Disk)
{
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.Disk']$")
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.BaseSubModule']/IMMIP$",$item_IMM.ipaddress)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.BaseSubModule']/IMMHostName$",$item_IMM.hostname)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.BaseSubModule']/UUID$",$item_IMM.uuid)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.BaseSubModule']/InbandComputerName$",$item_OShost.inbound_computername)
if ($item.DiskID -ne "")
{
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.Disk']/UniqueId$",$imm_DisplayName+"_"+$item.DiskID)
}
else
{
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.Disk']/UniqueId$",$imm_DisplayName+"_d"+$item.SlotNumber)
}
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.Disk']/DiskID$",$item.DiskID)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.Disk']/MaxMediaSize$",$item.MaxMediaSize)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.Disk']/Identifier$",$item.SystemName+"_"+$item.DiskID)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.Disk']/DiskType$",$item.DiskType)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.Disk']/PartNumber$",$item.PartNumber)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.Disk']/SerialNumber$",$item.SerialNumber)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.Disk']/FRUNumber$",$item.FRUNumber)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.Disk']/SensorNumber$",$item.SensorNumber)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.Disk']/Manufacture$",$item.Manufacture)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.Disk']/MediaType$",$item.MediaType)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.Disk']/RPM$",$item.RPM)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.Disk']/SystemName$",$item.SystemName)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.Disk']/SlotNumber$",$item.SlotNumber)
$instance.AddProperty("$MPElement[Name='Lenovo.HardwareMgmtPack.IMM2.Disk']/InterconnectSpeed$",$item.InterconnectSpeed)
$discoveryData.AddInstance($instance)
}
}
catch {
WriteLog 'exception happened' $RegDebug 5
$msg=$error[0]
WriteLog $msg $RegDebug 5
}
}
}while($next_page -eq "True")
$discoveryData
WriteLog 'IMM discovery done' $RegDebug 5
}
catch {
WriteLog 'error happened' $RegDebug 5
$msg=$error[0]
WriteLog $msg $RegDebug 5
}
finally{
$url = "https://localhost:" + $service_port + "/session/?operation=logout"
Invoke-WebRequest -Uri $url -UseBasicParsing -WebSession $fb | ConvertFrom-Json
WriteLog 'finally' $RegDebug 5
}
</Script></ScriptBody>
<Parameters>
<Parameter>
<Name>sourceId</Name>
<Value>$MPElement$</Value>
</Parameter>
<Parameter>
<Name>managedEntityId</Name>
<Value>$Target/Id$</Value>
</Parameter>
</Parameters>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
</ProbeAction>
</MemberModules>
<Composition>
<Node ID="PSScript">
<Node ID="DS"/>
</Node>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.Discovery.Data</OutputType>
</DataSourceModuleType>