# check if it is proper Host Server we are running on
if ($PrincipalName -ieq $HostServer)
{
$aIPList = $IPList.split(';')
$aServerName = $ServerName.Split(';')
$aOpSystem = $OpSystem.Split(';')
$aNoCertCheck = $NoCertCheck.Split(';')
$aCIMPort = $CIMPort.Split(';')
# add ESXi servers from list
for ($i = 0; $i -le $IPList.Length; $i++) {
$hostname = $aServerName[$i]
$ipaddress = $aIPList[$i]
if ($hostname -match $ValidHostnameRegex) {
# try to determine network name for ESXi server
$NetworkName = $ipaddress
$nslookup = (Resolve-NSLookup $ipaddress)
if ($nslookup -ne $null -and !$nslookup.Name.Equals("")) {
$NetworkName = $nslookup.Name
} elseif (($hostname -ine "localhost" -and $hostname -ne "127.0.0.1") -and (Test-Connection -ComputerName $hostname -Count 2 -Quiet)) {
$NetworkName = $hostname
}
# add ESXi server to SCOM
$oInst = $oDiscoveryData.CreateClassInstance("$MPElement[Name='FTSESXSEED!Fujitsu.Servers.PRIMERGY.ESXiSeed.Server']$")
$oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", "$PrincipalName")
$oInst.AddProperty("$MPElement[Name='FTSESXSEED!Fujitsu.Servers.PRIMERGY.ESXiSeed.HostServer']/PrincipalName$", "$PrincipalName")
$oInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "$($aIPList[$i])")
$oInst.AddProperty("$MPElement[Name='FTSESXSEED!Fujitsu.Servers.PRIMERGY.ESXiSeed.Server']/PrincipalName$", "$hostname")
$oInst.AddProperty("$MPElement[Name='FTSESXSEED!Fujitsu.Servers.PRIMERGY.ESXiSeed.Server']/HostServer$", "$PrincipalName")
$oInst.AddProperty("$MPElement[Name='FTSESXSEED!Fujitsu.Servers.PRIMERGY.ESXiSeed.Server']/OperatingSystem$", "$($aOpSystem[$i])")
$oInst.AddProperty("$MPElement[Name='FTSESXSEED!Fujitsu.Servers.PRIMERGY.ESXiSeed.Server']/IPAddress$", "$ipaddress")
$oInst.AddProperty("$MPElement[Name='FTSESXSEED!Fujitsu.Servers.PRIMERGY.ESXiSeed.Server']/NetworkName$", "$NetworkName")
$oInst.AddProperty("$MPElement[Name='FTSESXSEED!Fujitsu.Servers.PRIMERGY.ESXiSeed.Server']/NoCertCheck$", "$($aNoCertCheck[$i])")
$oInst.AddProperty("$MPElement[Name='FTSESXSEED!Fujitsu.Servers.PRIMERGY.ESXiSeed.Server']/CIMPort$", $aCIMPort[$i])
$oDiscoveryData.AddInstance($oInst)
}
}
}