Microsoft.KnowledgeServices.SharePoint.Foundation.2010.SPWebApplication_Discovery

Microsoft.KnowledgeServices.SharePoint.Foundation.2010.SPWebApplication_Discovery (Discovery)

Discovery module for class Microsoft.KnowledgeServices.SharePoint.Foundation.2010.SPWebApplication

Element properties:

TargetMicrosoft.KnowledgeServices.SharePoint.Foundation.2010.SPFarm
EnabledTrue
Frequency29615
RemotableFalse

Object Discovery Details:

Discovered Classes and their attribuets:

Member Modules:

ID Module Type TypeId RunAs 
Microsoft.KnowledgeServices.SharePoint.Foundation.2010.SPWebApplication_Discovery DataSource Microsoft.Windows.TimedPowerShell.DiscoveryProvider Microsoft.SharePoint.Foundation.2010.AdminAccount

Source Code:

<Discovery ID="Microsoft.KnowledgeServices.SharePoint.Foundation.2010.SPWebApplication_Discovery" Enabled="true" Target="MicrosoftKnowledgeServicesSharePointFoundation2010Library!Microsoft.KnowledgeServices.SharePoint.Foundation.2010.SPFarm" ConfirmDelivery="true" Remotable="true" Priority="Normal">
<Category>Discovery</Category>
<DiscoveryTypes>
<DiscoveryClass TypeID="MicrosoftKnowledgeServicesSharePointFoundation2010Library!Microsoft.KnowledgeServices.SharePoint.Foundation.2010.SPWebApplication">
<Property TypeID="MicrosoftKnowledgeServicesSharePointFoundation2010Library!Microsoft.KnowledgeServices.SharePoint.Foundation.2010.SPWebApplication" PropertyID="FarmID"/>
<Property TypeID="MicrosoftKnowledgeServicesSharePointFoundation2010Library!Microsoft.KnowledgeServices.SharePoint.Foundation.2010.SPWebApplication" PropertyID="AppPath"/>
<Property TypeID="MicrosoftKnowledgeServicesSharePointFoundation2010Library!Microsoft.KnowledgeServices.SharePoint.Foundation.2010.SPWebApplication" PropertyID="ResponseUri"/>
<Property TypeID="MicrosoftKnowledgeServicesSharePointFoundation2010Library!Microsoft.KnowledgeServices.SharePoint.Foundation.2010.SPWebApplication" PropertyID="Authentication"/>
<Property TypeID="MicrosoftKnowledgeServicesSharePointFoundation2010Library!Microsoft.KnowledgeServices.SharePoint.Foundation.2010.SPWebApplication" PropertyID="AppPool"/>
<Property TypeID="MicrosoftKnowledgeServicesSharePointFoundation2010Library!Microsoft.KnowledgeServices.SharePoint.Foundation.2010.SPWebApplication" PropertyID="AppUser"/>
<Property TypeID="MicrosoftKnowledgeServicesSharePointFoundation2010Library!Microsoft.KnowledgeServices.SharePoint.Foundation.2010.SPWebApplication" PropertyID="AppName"/>
</DiscoveryClass>
</DiscoveryTypes>
<DataSource ID="Microsoft.KnowledgeServices.SharePoint.Foundation.2010.SPWebApplication_Discovery" RunAs="SharePoint!Microsoft.SharePoint.Foundation.2010.AdminAccount" TypeID="Windows!Microsoft.Windows.TimedPowerShell.DiscoveryProvider">
<IntervalSeconds>29615</IntervalSeconds>
<SyncTime/>
<ScriptName>SPWebApplication.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.SharePoint.Foundation.2010.SPWebApplication] ""$text"" $sev $eventId"
}
else
{
$this._scomAPI.LogScriptEvent("Advisor Script: Microsoft.KnowledgeServices.SharePoint.Foundation.2010.SPWebApplication", $eventId, $sev, $text)
}
}
$discovery | Add-Member -MemberType ScriptMethod -Name "WriteDiscoveryDebugLog" -Value {
$u = [Environment]::UserDomainName + "\" + [Environment]::UserName
$date = Get-Date
$header = "$date`tMicrosoft.KnowledgeServices.SharePoint.Foundation.2010.SPWebApplication`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.SharePoint.Foundation.2010.SPWebApplication"
}

$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.SharePoint.Foundation.2010.SPWebApplication"
{
$instance = $this._discoveryData.CreateClassInstance("$MPElement[Name='MicrosoftKnowledgeServicesSharePointFoundation2010Library!Microsoft.KnowledgeServices.SharePoint.Foundation.2010.SPWebApplication']$")

_AdvisorAddProperty $instance "$MPElement[Name='MicrosoftKnowledgeServicesSharePointFoundation2010Library!Microsoft.KnowledgeServices.SharePoint.Foundation.2010.SPWebApplication']/FarmID$" $o.FarmID $true
_AdvisorAddProperty $instance "$MPElement[Name='MicrosoftKnowledgeServicesSharePointFoundation2010Library!Microsoft.KnowledgeServices.SharePoint.Foundation.2010.SPWebApplication']/AppPath$" $o.AppPath $true
_AdvisorAddProperty $instance "$MPElement[Name='MicrosoftKnowledgeServicesSharePointFoundation2010Library!Microsoft.KnowledgeServices.SharePoint.Foundation.2010.SPWebApplication']/ResponseUri$" $o.ResponseUri $false
_AdvisorAddProperty $instance "$MPElement[Name='MicrosoftKnowledgeServicesSharePointFoundation2010Library!Microsoft.KnowledgeServices.SharePoint.Foundation.2010.SPWebApplication']/Authentication$" $o.Authentication $false
_AdvisorAddProperty $instance "$MPElement[Name='MicrosoftKnowledgeServicesSharePointFoundation2010Library!Microsoft.KnowledgeServices.SharePoint.Foundation.2010.SPWebApplication']/AppPool$" $o.AppPool $false
_AdvisorAddProperty $instance "$MPElement[Name='MicrosoftKnowledgeServicesSharePointFoundation2010Library!Microsoft.KnowledgeServices.SharePoint.Foundation.2010.SPWebApplication']/AppUser$" $o.AppUser $false
_AdvisorAddProperty $instance "$MPElement[Name='MicrosoftKnowledgeServicesSharePointFoundation2010Library!Microsoft.KnowledgeServices.SharePoint.Foundation.2010.SPWebApplication']/AppName$" $o.AppName $false
_AdvisorAddProperty $instance "$MPElement[Name='System!System.Entity']/DisplayName$" $o.DisplayName $false
_AdvisorAddProperty $instance "$MPElement[Name='MicrosoftKnowledgeServicesSharePointFoundation2010Library!Microsoft.KnowledgeServices.SharePoint.Foundation.2010.SPFarm']/FarmID$" $this.ParentClass.FarmID $true
_AdvisorAddProperty $instance "$MPElement[Name='MicrosoftKnowledgeServicesSharePointFoundation2010Library!Microsoft.KnowledgeServices.SharePoint.Foundation.2010.SPFarm']/FarmName$" $this.ParentClass.FarmName $true
_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.SharePoint.Foundation.2010.SPWebApplication"
{
$o = New-Object PSObject
$o | Add-Member -MemberType NoteProperty -Name ClassName -Value $className
$o | Add-Member -MemberType NoteProperty -Name DisplayName -Value "Sharepoint Web Application"

$o | Add-Member -MemberType NoteProperty -Name "FarmID" -Value $null -Force
$o | Add-Member -MemberType NoteProperty -Name "AppPath" -Value $null -Force
$o | Add-Member -MemberType NoteProperty -Name "ResponseUri" -Value $null -Force
$o | Add-Member -MemberType NoteProperty -Name "Authentication" -Value $null -Force
$o | Add-Member -MemberType NoteProperty -Name "AppPool" -Value $null -Force
$o | Add-Member -MemberType NoteProperty -Name "AppUser" -Value $null -Force
$o | Add-Member -MemberType NoteProperty -Name "AppName" -Value $null -Force


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



$current = _AdvisorCreateBaseObject "Microsoft.KnowledgeServices.SharePoint.Foundation.2010.SPFarm" ""
$current | Add-Member -MemberType NoteProperty -Name "FarmID" -Value "$Target/Property[Type="MicrosoftKnowledgeServicesSharePointFoundation2010Library!Microsoft.KnowledgeServices.SharePoint.Foundation.2010.SPFarm"]/FarmID$" -Force
$current | Add-Member -MemberType NoteProperty -Name "FarmName" -Value "$Target/Property[Type="MicrosoftKnowledgeServicesSharePointFoundation2010Library!Microsoft.KnowledgeServices.SharePoint.Foundation.2010.SPFarm"]/FarmName$" -Force
$current | Add-Member -MemberType NoteProperty -Name "isSPDiagInstalled" -Value $null -Force;$current.isSPDiagInstalled = _AdvisorGetTypedValue "Boolean" "$Target/Property[Type="MicrosoftKnowledgeServicesSharePointFoundation2010Library!Microsoft.KnowledgeServices.SharePoint.Foundation.2010.SPFarm"]/isSPDiagInstalled$"
$current | Add-Member -MemberType NoteProperty -Name "SPVersion" -Value "$Target/Property[Type="MicrosoftKnowledgeServicesSharePointFoundation2010Library!Microsoft.KnowledgeServices.SharePoint.Foundation.2010.SPFarm"]/SPVersion$" -Force
$current | Add-Member -MemberType NoteProperty -Name "SPMajorVersion" -Value $null -Force;$current.SPMajorVersion = _AdvisorGetTypedValue "Integer" "$Target/Property[Type="MicrosoftKnowledgeServicesSharePointFoundation2010Library!Microsoft.KnowledgeServices.SharePoint.Foundation.2010.SPFarm"]/SPMajorVersion$"
$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


[ScriptBlock]$mainScriptBlock = {




function Handle-Errors([string]$ErrMsg)
{
if (! $error)
{
return;
}
$ErrorString = $ErrMsg;

$EventLog_Format = "`nCurrent PID: {0}`nInvocationInfo.MyCommand: {1}`nInvocationInfo.ScriptLineNumber: {2}`nInvocationInfo.OffsetInLine: {3}`nInvocationInfo.ScriptName: {4}`nInvocationInfo.Line: {5}`nInvocationInfo.PositionMessage: {6}`nInvocationInfo.InvocationName: {7}`nInvocationInfo.PipelineLength: {8}`nInvocationInfo.PipelinePosition: {9}`n";

$EventLog_Template = "[{0} in Advisor script] {1} {2}";
$Exception = $error[$error.Count - 1];
if ($Exception.InvocationInfo -ne $null)
{
$ErrorString += ($EventLog_Format -f $pid, $Exception.InvocationInfo.MyCommand,
$Exception.InvocationInfo.ScriptLineNumber, $Exception.InvocationInfo.OffsetInLine, $Exception.InvocationInfo.ScriptName,
$Exception.InvocationInfo.Line, $Exception.InvocationInfo.PositionMessage, $Exception.InvocationInfo.InvocationName,
$Exception.InvocationInfo.PipelineLength, $Exception.InvocationInfo.PipelinePosition);
}

if ($null -ne $Exception.Exception)
{
$Exception = $Exception.Exception;
}
$InnerException = $Exception;
if ($null -ne $Exception.InnerException)
{
$InnerException = $Exception.InnerException;
}

$EventObject = New-Object Diagnostics.EventLog;
$EventObject.Source = "Operations Manager"
$EventObject.WriteEntry(($EventLog_Template -f $InnerException.GetType().FullName, $ErrorString, $Exception.Message), [System.Diagnostics.EventLogEntryType]::Error, 8000);
$error.Clear();
}

Function IsSharePointEnvironmentPrepared
{
$isPrepared = $true


try
{
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
}
catch
{
$isPrepared = $false
}

if ($null -eq [Microsoft.SharePoint.Administration.SPServer]::Local)
{
$isPrepared = $false
}
$error.Clear()
return $isPrepared
}

function CreateInstances($service)
{
foreach ($webApp in $service.WebApplications)
{
$temp = New-Object psobject
$temp | Add-Member -MemberType NoteProperty -Name "FarmID" -Value ""
$temp | Add-Member -MemberType NoteProperty -Name "AppPath" -Value ""
$temp | Add-Member -MemberType NoteProperty -Name "ResponseUri" -Value ""
$temp | Add-Member -MemberType NoteProperty -Name "Authentication" -Value ""
$temp | Add-Member -MemberType NoteProperty -Name "AppPool" -Value ""
$temp | Add-Member -MemberType NoteProperty -Name "AppUser" -Value ""
$temp | Add-Member -MemberType NoteProperty -Name "AppName" -Value ""

if ([Microsoft.SharePoint.Administration.SPObjectStatus]::Online -ne $webApp.Status)
{
continue;
}

$iisSettings = $webApp.IisSettings;

$defaultZone = [Microsoft.SharePoint.Administration.SPUrlZone]::Default;
$webAppSettings = $iisSettings[$defaultZone]

if ($webAppSettings -eq $null)
{
continue;
}

$temp.FarmID = [string]$webApp.Farm.Id;
$temp.AppPath = $webAppSettings.Path.FullName;
$temp.ResponseUri = $WebApp.GetResponseUri($DefaultZone).AbsoluteUri;
$temp.Authentication = $webAppSettings.AuthenticationMode.ToString();
$temp.AppPool = $WebApp.ApplicationPool.Name;
$temp.AppUser = $WebApp.ApplicationPool.Username;
$temp.AppName = $webApp.DisplayName;
$global:advisorDiscoveredObjects += $temp
}
}





function WebApplicationDiscovery()
{
Try
{
if ((IsSharePointEnvironmentPrepared) -eq $true)
{
$global:advisorDiscoveredObjects = @()
$arrayServices = @()
$AdminWebService = [Microsoft.SharePoint.Administration.SPWebService]::AdministrationService;
$ContentWebService = [Microsoft.SharePoint.Administration.SPWebService]::ContentService;
$arrayServices += $AdminWebService
$arrayServices += $ContentWebService
foreach($arrayService in $arrayServices)
{
CreateInstances($arrayService)
}
}
}
Catch
{
Handle-Errors "SPWebApplication"
}
}

WebApplicationDiscovery

}

Function Test-NeedPSRemoting
{
$script:SharePointPSVer = 0
$registryKey2010 = "HKLM:\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\14.0"
$registryKey2013 = "HKLM:\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\15.0"

if (Test-Path -Path $registryKey2010)
{
if ((Get-ItemProperty -Path $registryKey2010 -ErrorAction SilentlyContinue).Sharepoint -eq "Installed")
{
$script:SharePointPSVer = 2010
}
}
if (Test-Path -Path $registryKey2013)
{
if ((Get-ItemProperty -Path $registryKey2013 -ErrorAction SilentlyContinue).Sharepoint -eq "Installed")
{
$script:SharePointPSVer = 2013
}
}

$PSCLRVersion = [System.String]::Format("{0}.{1}", $PSVersionTable.CLRVersion.Major, $PSVersionTable.CLRVersion.Minor)
if (($PSCLRVersion -ieq "2.0") -and ($script:SharePointPSVer -ieq 2013))
{
return $true
}
return $false
}

if ((Test-NeedPSRemoting))
{
[bool]$script:psRemotingEnabled = $false

$winRMService = (Get-Service WinRM -ErrorAction SilentlyContinue)
if ($winRMService -ne $null)
{
if ($winRMService.Status -ieq [System.ServiceProcess.ServiceControllerStatus]::Stopped)
{
$winRMService.Start()
$winRMService.WaitForStatus([System.ServiceProcess.ServiceControllerStatus]::Running, [System.TimeSpan]::FromSeconds(15))
}
$psSessionConfiguration = (Get-PSSessionConfiguration -Name "Microsoft.PowerShell" -ErrorAction SilentlyContinue)
if ($psSessionConfiguration.Permission.Contains("BUILTIN\Administrators AccessAllowed"))
{
winrm quickconfig -quiet
$script:psRemotingEnabled = $true
}
else
{
Enable-PSRemoting -Force
winrm quickconfig -quiet
$script:psRemotingEnabled = $true
Set-Item WSMan:\localhost\Shell\MaxShellsPerUser 50
}
}


if ($script:psRemotingEnabled -eq $true)
{
$session = New-PSSession
Invoke-Command -Session $session -ScriptBlock $mainScriptBlock
$global:advisorDiscoveredObjects = Invoke-Command -Session $session -ScriptBlock {$global:advisorDiscoveredObjects}
Remove-PSSession -Session $session
}
}
else
{
&amp; $mainScriptBlock
}

Function AddDiscoveryInstance($discoveredObjects)
{
foreach($item in $discoveredObjects)
{
$app = $discovery.CreateClassInstance()
$app.FarmID = $item.FarmID
$app.AppPath = $item.AppPath
$app.ResponseUri = $item.ResponseUri
$app.Authentication = $item.Authentication
$app.AppPool = $item.AppPool
$app.AppUser = $item.AppUser
$app.AppName = $item.AppName
$discovery.AddInstance( $app )
}
}

if ($global:advisorDiscoveredObjects -ne $null)
{
AddDiscoveryInstance $global:advisorDiscoveredObjects
}

$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>