Microsoft.KnowledgeServices.VMM.2012.VMMAgent_Discovery

Microsoft.KnowledgeServices.VMM.2012.VMMAgent_Discovery (Discovery)

Discovery module for class Microsoft.KnowledgeServices.VMM.2012.VMMAgent

Element properties:

TargetMicrosoft.KnowledgeServices.VMM.2012.VMMServer
EnabledTrue
Frequency16230
RemotableFalse

Object Discovery Details:

Discovered Classes and their attribuets:

Member Modules:

ID Module Type TypeId RunAs 
Microsoft.KnowledgeServices.VMM.2012.VMMAgent_Discovery DataSource Microsoft.Windows.TimedPowerShell.DiscoveryProvider Microsoft.KnowledgeServices.ElevatedAccount.VMM

Source Code:

<Discovery ID="Microsoft.KnowledgeServices.VMM.2012.VMMAgent_Discovery" Enabled="true" Target="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer" ConfirmDelivery="true" Remotable="true" Priority="Normal">
<Category>Discovery</Category>
<DiscoveryTypes>
<DiscoveryClass TypeID="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMAgent">
<Property TypeID="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMAgent" PropertyID="AdminShareExists"/>
<Property TypeID="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMAgent" PropertyID="ProductVersion"/>
<Property TypeID="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMAgent" PropertyID="VirtualizationPlatform"/>
<Property TypeID="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMAgent" PropertyID="AgentCompatibleWithServer"/>
<Property TypeID="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMAgent" PropertyID="BITSTcpPort"/>
<Property TypeID="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMAgent" PropertyID="FQDN"/>
</DiscoveryClass>
</DiscoveryTypes>
<DataSource ID="Microsoft.KnowledgeServices.VMM.2012.VMMAgent_Discovery" RunAs="KnowledgeServices!Microsoft.KnowledgeServices.ElevatedAccount.VMM" TypeID="Windows!Microsoft.Windows.TimedPowerShell.DiscoveryProvider">
<IntervalSeconds>16230</IntervalSeconds>
<SyncTime/>
<ScriptName>VMMAgent.ps1</ScriptName>
<ScriptBody><Script>

param($SourceId,$ManagedEntityId)

$ErrorActionPreference = "Stop"


function _AdvisorGetTypedValue()
{
param([string] $type, [string] $v)
if (($type -eq "String") -or ($v -eq $null) )
{
return $v
}
if ($v.Trim().Length -gt 0)
{
switch ($type)
{
"Boolean" { if ($v -eq "true") {$true} else {$false} }
"DateTime" { [System.DateTime]::Parse($v) }
"Guid" { New-Object System.Guid($v) }
"Integer" { [int]$v }
"Float" { [float]$v }
}
}
else
{
$null
}
}
function _AdvisorAddProperty()
{
param([object]$o, [string]$p, [object]$v, [bool]$key)
if (($key -eq $true) -and ($v -eq $null))
{
Throw "Key property [$p] cannot be null."
}
if ($v -ne $null)
{
$o.AddProperty($p, $v)
}
}
function _AdvisorCreateBaseObject([string] $className, [string] $displayName)
{
$o = new-object PSObject
$o | Add-Member -MemberType NoteProperty -Name "ClassName" -Value $className
$o | Add-Member -MemberType NoteProperty -Name "DisplayName" -Value $displayName
$o | Add-Member -MemberType NoteProperty -Name "ParentClass" -Value $null
return $o
}


$scriptargs = new-object psobject
$scriptargs | add-member NoteProperty "SourceId" $SourceId
$scriptargs | add-member NoteProperty "ManagedEntityId" $ManagedEntityId


if (!$global:AdvisorEmulateRuntime)
{
$oAPI = new-object -comObject "MOM.ScriptAPI"
}


$discovery = New-Object PSObject
$discovery | Add-Member -MemberType NoteProperty -Name "_logFile" -Value $null
$discovery | Add-Member -MemberType NoteProperty -Name "_scomAPI" -Value $oAPI
$discovery | Add-Member -MemberType NoteProperty -Name "_discoveryData" -Value $null
$discovery | Add-Member -MemberType NoteProperty -Name "ParentClass" -Value $null
$discovery | Add-Member -MemberType NoteProperty -Name "Classes" -Value @()
$discovery | Add-Member -MemberType ScriptMethod -Name "AddInstance" -Value {
$o = $args[0]
$this.WriteDiscoveryDebugLog( "-Instance Added-", $o )
$this.Classes += $o
}
$discovery | Add-Member -MemberType ScriptMethod -Name "WriteEventLog" -Value {
$text = $args[0]
$eventId = $args[1]
$sev = $args[2]
if (($sev -eq $null) -or ($sev -gt 4)) { $sev = 0 }
if (($eventId -eq $null) -or ($eventId -lt 0) -or ($eventId -gt 20000)) { $eventId = 19000 }
if ($global:AdvisorEmulateRuntime)
{
Write-Debug "[Advisor Script(EventLog): Microsoft.KnowledgeServices.VMM.2012.VMMAgent] ""$text"" $sev $eventId"
}
else
{
$this._scomAPI.LogScriptEvent("Advisor Script: Microsoft.KnowledgeServices.VMM.2012.VMMAgent", $eventId, $sev, $text)
}
}
$discovery | Add-Member -MemberType ScriptMethod -Name "WriteDiscoveryDebugLog" -Value {
$u = [Environment]::UserDomainName + "\" + [Environment]::UserName
$date = Get-Date
$header = "$date`tMicrosoft.KnowledgeServices.VMM.2012.VMMAgent`t$u"
if (($args -ne $null) -and ($args.Count -gt 0) -and ($args[0] -is [string]))
{
$header += "`t" + $args[0]
$args = @($args | Select-Object -Last ($args.Count-1))
}
$output = @($header, $args)
$output | Out-String -Width 256 | Write-Debug
if ($this._logFile -ne $null)
{
$output | Out-String | Add-Content -Path $this._logFile
}
}
$discovery | Add-Member -MemberType ScriptMethod -Name "CreateClassInstance" -Value {
return AdvisorCreateClassInstance "Microsoft.KnowledgeServices.VMM.2012.VMMAgent"
}

$discoveryDebugFilePath = Join-Path $Env:ProgramFiles "\System Center Advisor\discovery.txt"
if (Test-Path $discoveryDebugFilePath)
{
$discovery._logFile = $discoveryDebugFilePath
}
del variable:\discoveryDebugFilePath -force &#x2013;ErrorAction SilentlyContinue

$discovery | Add-Member -MemberType ScriptMethod -Name "CreateDiscoveryData" -Value {
if ($global:AdvisorEmulateRuntime)
{
$i = 0
foreach ($o in $this.Classes)
{
$i = $i + 1
$this.WriteDiscoveryDebugLog("Discovered Class $i", $o )
}
}
else
{
$this._discoveryData = $this._scomAPI.CreateDiscoveryData(0, $scriptargs.SourceId, $scriptargs.ManagedEntityId)
foreach ($o in $this.Classes)
{
$instance = $null
switch ($o.ClassName)
{
"Microsoft.KnowledgeServices.VMM.2012.VMMAgent"
{
$instance = $this._discoveryData.CreateClassInstance("$MPElement[Name='MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMAgent']$")

_AdvisorAddProperty $instance "$MPElement[Name='MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMAgent']/AdminShareExists$" $o.AdminShareExists $false
_AdvisorAddProperty $instance "$MPElement[Name='MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMAgent']/ProductVersion$" $o.ProductVersion $false
_AdvisorAddProperty $instance "$MPElement[Name='MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMAgent']/VirtualizationPlatform$" $o.VirtualizationPlatform $false
_AdvisorAddProperty $instance "$MPElement[Name='MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMAgent']/AgentCompatibleWithServer$" $o.AgentCompatibleWithServer $false
_AdvisorAddProperty $instance "$MPElement[Name='MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMAgent']/BITSTcpPort$" $o.BITSTcpPort $false
_AdvisorAddProperty $instance "$MPElement[Name='MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMAgent']/FQDN$" $o.FQDN $true
_AdvisorAddProperty $instance "$MPElement[Name='System!System.Entity']/DisplayName$" $o.DisplayName $false
_AdvisorAddProperty $instance "$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$" $this.ParentClass.ParentClass.PrincipalName $true


}
default {Throw "Unsupported ClassName: " + $o.ClassName}
}
$this._discoveryData.AddInstance($instance)
}
return $this._discoveryData
}
}

function AdvisorCreateClassInstance([string] $className)
{
$o = $null
switch ($className)
{
"Microsoft.KnowledgeServices.VMM.2012.VMMAgent"
{
$o = New-Object PSObject
$o | Add-Member -MemberType NoteProperty -Name ClassName -Value $className
$o | Add-Member -MemberType NoteProperty -Name DisplayName -Value "VMMAgent"

$o | Add-Member -MemberType NoteProperty -Name "AdminShareExists" -Value $null -Force
$o | Add-Member -MemberType NoteProperty -Name "ProductVersion" -Value $null -Force
$o | Add-Member -MemberType NoteProperty -Name "VirtualizationPlatform" -Value $null -Force
$o | Add-Member -MemberType NoteProperty -Name "AgentCompatibleWithServer" -Value $null -Force
$o | Add-Member -MemberType NoteProperty -Name "BITSTcpPort" -Value $null -Force
$o | Add-Member -MemberType NoteProperty -Name "FQDN" -Value $null -Force


}
default {Throw "Unsupported ClassName: " + $className}
}
return $o
}



$current = _AdvisorCreateBaseObject "Microsoft.KnowledgeServices.VMM.2012.VMMServer" ""
$current | Add-Member -MemberType NoteProperty -Name "ProductVersion" -Value "$Target/Property[Type="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer"]/ProductVersion$" -Force
$current | Add-Member -MemberType NoteProperty -Name "CompatibleMPVersion" -Value "$Target/Property[Type="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer"]/CompatibleMPVersion$" -Force
$current | Add-Member -MemberType NoteProperty -Name "AgentVersion" -Value "$Target/Property[Type="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer"]/AgentVersion$" -Force
$current | Add-Member -MemberType NoteProperty -Name "GuestAgentVersion" -Value "$Target/Property[Type="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer"]/GuestAgentVersion$" -Force
$current | Add-Member -MemberType NoteProperty -Name "VmmID" -Value "$Target/Property[Type="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer"]/VmmID$" -Force
$current | Add-Member -MemberType NoteProperty -Name "VmmServiceAccount" -Value "$Target/Property[Type="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer"]/VmmServiceAccount$" -Force
$current | Add-Member -MemberType NoteProperty -Name "VmmServicePrincipalNames" -Value "$Target/Property[Type="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer"]/VmmServicePrincipalNames$" -Force
$current | Add-Member -MemberType NoteProperty -Name "Port" -Value "$Target/Property[Type="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer"]/Port$" -Force
$current | Add-Member -MemberType NoteProperty -Name "IsConnected" -Value "$Target/Property[Type="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer"]/IsConnected$" -Force
$current | Add-Member -MemberType NoteProperty -Name "ServerInterfaceVersion" -Value "$Target/Property[Type="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer"]/ServerInterfaceVersion$" -Force
$current | Add-Member -MemberType NoteProperty -Name "Profile" -Value "$Target/Property[Type="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer"]/Profile$" -Force
$current | Add-Member -MemberType NoteProperty -Name "UserRole" -Value "$Target/Property[Type="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer"]/UserRole$" -Force
$current | Add-Member -MemberType NoteProperty -Name "UserRoleId" -Value "$Target/Property[Type="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer"]/UserRoleId$" -Force
$current | Add-Member -MemberType NoteProperty -Name "FullyQualifiedDomainName" -Value "$Target/Property[Type="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer"]/FullyQualifiedDomainName$" -Force
$current | Add-Member -MemberType NoteProperty -Name "OpsMgrServer" -Value "$Target/Property[Type="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer"]/OpsMgrServer$" -Force
$current | Add-Member -MemberType NoteProperty -Name "VMRCAccessAccount" -Value "$Target/Property[Type="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer"]/VMRCAccessAccount$" -Force
$current | Add-Member -MemberType NoteProperty -Name "VMRCDefaultPort" -Value "$Target/Property[Type="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer"]/VMRCDefaultPort$" -Force
$current | Add-Member -MemberType NoteProperty -Name "VMConnectDefaultPort" -Value "$Target/Property[Type="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer"]/VMConnectDefaultPort$" -Force
$current | Add-Member -MemberType NoteProperty -Name "MinimumSupportedAgentVersion" -Value "$Target/Property[Type="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer"]/MinimumSupportedAgentVersion$" -Force
$current | Add-Member -MemberType NoteProperty -Name "MinimumSupportedGuestAgentVersion" -Value "$Target/Property[Type="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer"]/MinimumSupportedGuestAgentVersion$" -Force
$current | Add-Member -MemberType NoteProperty -Name "LibraryRefresherEnabled" -Value "$Target/Property[Type="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer"]/LibraryRefresherEnabled$" -Force
$current | Add-Member -MemberType NoteProperty -Name "LibraryRefresherFrequency" -Value "$Target/Property[Type="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer"]/LibraryRefresherFrequency$" -Force
$current | Add-Member -MemberType NoteProperty -Name "DatabaseServerName" -Value "$Target/Property[Type="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer"]/DatabaseServerName$" -Force
$current | Add-Member -MemberType NoteProperty -Name "DatabaseInstanceName" -Value "$Target/Property[Type="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer"]/DatabaseInstanceName$" -Force
$current | Add-Member -MemberType NoteProperty -Name "DatabaseName" -Value "$Target/Property[Type="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer"]/DatabaseName$" -Force
$current | Add-Member -MemberType NoteProperty -Name "UserName" -Value "$Target/Property[Type="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer"]/UserName$" -Force
$current | Add-Member -MemberType NoteProperty -Name "CompanyName" -Value "$Target/Property[Type="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer"]/CompanyName$" -Force
$current | Add-Member -MemberType NoteProperty -Name "ProductId" -Value "$Target/Property[Type="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer"]/ProductId$" -Force
$current | Add-Member -MemberType NoteProperty -Name "LicenseType" -Value "$Target/Property[Type="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer"]/LicenseType$" -Force
$current | Add-Member -MemberType NoteProperty -Name "IsHighlyAvailable" -Value "$Target/Property[Type="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer"]/IsHighlyAvailable$" -Force
$current | Add-Member -MemberType NoteProperty -Name "FailoverVMMNodes" -Value "$Target/Property[Type="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer"]/FailoverVMMNodes$" -Force
$current | Add-Member -MemberType NoteProperty -Name "ActiveVMMNode" -Value "$Target/Property[Type="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer"]/ActiveVMMNode$" -Force
$current | Add-Member -MemberType NoteProperty -Name "AutomaticLogicalNetworkCreationEnabled" -Value "$Target/Property[Type="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer"]/AutomaticLogicalNetworkCreationEnabled$" -Force
$current | Add-Member -MemberType NoteProperty -Name "AutomaticVirtualNetworkCreationEnabled" -Value "$Target/Property[Type="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer"]/AutomaticVirtualNetworkCreationEnabled$" -Force
$current | Add-Member -MemberType NoteProperty -Name "LogicalNetworkMatchOption" -Value "$Target/Property[Type="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer"]/LogicalNetworkMatchOption$" -Force
$current | Add-Member -MemberType NoteProperty -Name "BackupLogicalNetworkMatchOption" -Value "$Target/Property[Type="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer"]/BackupLogicalNetworkMatchOption$" -Force
$current | Add-Member -MemberType NoteProperty -Name "ForOnBehalfOf" -Value "$Target/Property[Type="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer"]/ForOnBehalfOf$" -Force
$current | Add-Member -MemberType NoteProperty -Name "CEIPOptin" -Value "$Target/Property[Type="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer"]/CEIPOptin$" -Force
$current | Add-Member -MemberType NoteProperty -Name "UnsupportedSQLVersion" -Value $null -Force;$current.UnsupportedSQLVersion = _AdvisorGetTypedValue "Boolean" "$Target/Property[Type="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer"]/UnsupportedSQLVersion$"
$current | Add-Member -MemberType NoteProperty -Name "VMMRelease" -Value "$Target/Property[Type="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer"]/VMMRelease$" -Force
$current | Add-Member -MemberType NoteProperty -Name "SQLRelease" -Value "$Target/Property[Type="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer"]/SQLRelease$" -Force
$current | Add-Member -MemberType NoteProperty -Name "SQLVersion" -Value "$Target/Property[Type="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer"]/SQLVersion$" -Force
$current | Add-Member -MemberType NoteProperty -Name "SQLEdition" -Value "$Target/Property[Type="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer"]/SQLEdition$" -Force
$current | Add-Member -MemberType NoteProperty -Name "BITSTcpPort" -Value $null -Force;$current.BITSTcpPort = _AdvisorGetTypedValue "Integer" "$Target/Property[Type="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer"]/BITSTcpPort$"
$current | Add-Member -MemberType NoteProperty -Name "OSVersion" -Value "$Target/Property[Type="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer"]/OSVersion$" -Force
$current | Add-Member -MemberType NoteProperty -Name "OSRelease" -Value "$Target/Property[Type="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer"]/OSRelease$" -Force
$current | Add-Member -MemberType NoteProperty -Name "OSServicePack" -Value "$Target/Property[Type="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer"]/OSServicePack$" -Force
$current | Add-Member -MemberType NoteProperty -Name "InstallPath" -Value "$Target/Property[Type="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer"]/InstallPath$" -Force
$current | Add-Member -MemberType NoteProperty -Name "TempPath" -Value "$Target/Property[Type="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer"]/TempPath$" -Force
$current | Add-Member -MemberType NoteProperty -Name "NumberOfManagedHosts" -Value $null -Force;$current.NumberOfManagedHosts = _AdvisorGetTypedValue "Integer" "$Target/Property[Type="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer"]/NumberOfManagedHosts$"
$current | Add-Member -MemberType NoteProperty -Name "SQLProductLevel" -Value "$Target/Property[Type="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer"]/SQLProductLevel$" -Force
$current | Add-Member -MemberType NoteProperty -Name "EvaluationDaysLeft" -Value $null -Force;$current.EvaluationDaysLeft = _AdvisorGetTypedValue "Integer" "$Target/Property[Type="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer"]/EvaluationDaysLeft$"
$current | Add-Member -MemberType NoteProperty -Name "DisplayName" -Value "$Target/Property[Type="System!System.Entity"]/DisplayName$" -Force

$discovery.ParentClass = $current
$current = _AdvisorCreateBaseObject "Microsoft.Windows.Computer" ""
$current | Add-Member -MemberType NoteProperty -Name "PrincipalName" -Value "$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName$" -Force
$current | Add-Member -MemberType NoteProperty -Name "DNSName" -Value "$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/DNSName$" -Force
$current | Add-Member -MemberType NoteProperty -Name "NetbiosComputerName" -Value "$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/NetbiosComputerName$" -Force
$current | Add-Member -MemberType NoteProperty -Name "NetbiosDomainName" -Value "$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/NetbiosDomainName$" -Force
$current | Add-Member -MemberType NoteProperty -Name "IPAddress" -Value "$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/IPAddress$" -Force
$current | Add-Member -MemberType NoteProperty -Name "NetworkName" -Value "$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/NetworkName$" -Force
$current | Add-Member -MemberType NoteProperty -Name "ActiveDirectoryObjectSid" -Value "$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/ActiveDirectoryObjectSid$" -Force
$current | Add-Member -MemberType NoteProperty -Name "IsVirtualMachine" -Value $null -Force;$current.IsVirtualMachine = _AdvisorGetTypedValue "Boolean" "$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/IsVirtualMachine$"
$current | Add-Member -MemberType NoteProperty -Name "DomainDnsName" -Value "$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/DomainDnsName$" -Force
$current | Add-Member -MemberType NoteProperty -Name "OrganizationalUnit" -Value "$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/OrganizationalUnit$" -Force
$current | Add-Member -MemberType NoteProperty -Name "ForestDnsName" -Value "$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/ForestDnsName$" -Force
$current | Add-Member -MemberType NoteProperty -Name "ActiveDirectorySite" -Value "$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/ActiveDirectorySite$" -Force
$current | Add-Member -MemberType NoteProperty -Name "LogicalProcessors" -Value $null -Force;$current.LogicalProcessors = _AdvisorGetTypedValue "Integer" "$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/LogicalProcessors$"
$current | Add-Member -MemberType NoteProperty -Name "DisplayName" -Value "$Target/Property[Type="System!System.Entity"]/DisplayName$" -Force

$discovery.ParentClass.ParentClass = $current







$setupKeyExists = Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Microsoft System Center Virtual Machine Manager Server\Setup"

if ($setupKeyExists)
{
$setupKey = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Microsoft System Center Virtual Machine Manager Server\Setup"

Set-ExecutionPolicy -Scope Process RemoteSigned -Force




$modulePath = $setupKey.InstallPath + "bin\psModules\virtualmachinemanager\virtualmachinemanager.psd1";

import-module $modulePath;

Try
{
$script:config = Get-VMMServer "localhost";
}
Catch [Microsoft.VirtualManager.Utils.CarmineException]
{

return
}

$requiredAgentVersion = $config.MinimumSupportedAgentVersion;

$vmHosts = Get-VMHost;

foreach ($vmHost in $vmHosts) {

$instance = $discovery.CreateClassInstance();

$hostName = $vmHost.Name;

$instance.DisplayName = $hostName;

$instance.AgentCompatibleWithServer = $false;

$instance.FQDN = $vmHost.FQDN;

$instance.VirtualizationPlatform = $vmHost.VirtualizationPlatform.ToString();


if ($vmHost.VirtualizationPlatform -eq "HyperV")
{
try
{
$version = (Invoke-WSManAction -Action GetVersion -ResourceURI wmi/root/scvmm/AgentManagement -ComputerName $hostName).Version;

$parsedAgentVersion = New-Object -TypeName System.Version $version;
$parsedRequiredAgentVersion = New-Object -TypeName System.Version $requiredAgentVersion;

if ($parsedAgentVersion -ge $parsedRequiredAgentVersion)
{
$instance.AgentCompatibleWithServer = $true;
}
}
catch
{
$version = "unknown - error";
}
}
else
{
$version = "unknown - non HyperV";
}

$instance.ProductVersion = $version;



try
{

$tryAcess = Get-Item -LiteralPath "\\$hostName\Admin$"

$instance.AdminShareExists = $true;
}
catch
{
$instance.AdminShareExists = $false;
}



try
{
$remoteRegistry = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey("LocalMachine", $hostName);
$setupKey = $remoteRegistry.OpenSubKey("SOFTWARE\Microsoft\Microsoft System Center Virtual Machine Manager Agent\Setup");

$instance.BITSTcpPort = $setupKey.GetValue("BITSTcpPort");
}
catch
{
$instance.BITSTcpPort = -1;
}

$discovery.AddInstance($instance);
}
}


$discoverydata = $discovery.CreateDiscoveryData()
$discoverydata

</Script></ScriptBody>
<Parameters>
<Parameter>
<Name>SourceId</Name>
<Value>$MPElement$</Value>
</Parameter>
<Parameter>
<Name>ManagedEntityId</Name>
<Value>$Target/Id$</Value>
</Parameter>
</Parameters>
<TimeoutSeconds>300</TimeoutSeconds>
<StrictErrorHandling>false</StrictErrorHandling>
</DataSource>
</Discovery>