Ermittlung referenzierter Datenquellen
Microsoft.SystemCenter.DataProtectionManager.2011.Discovery.ReferencedDSDiscovery (Discovery)
Element properties: Object Discovery Details: Member Modules:
Source Code: <Discovery ID="Microsoft.SystemCenter.DataProtectionManager.2011.Discovery.ReferencedDSDiscovery" Enabled="true" Target="SCDPM!Microsoft.SystemCenter.DataProtectionManager.2011.Library.ProtectionGroup" ConfirmDelivery="true" Remotable="true" Priority="Normal">
<Category>Discovery</Category>
<DiscoveryTypes>
<DiscoveryClass TypeID="SCDPM!Microsoft.SystemCenter.DataProtectionManager.2011.Library.ReferencedDatasource"/>
<DiscoveryRelationship TypeID="SCDPM!Microsoft.SystemCenter.DataProtectionManager.2011.Library.PGHostsReferencedDatasource"/>
</DiscoveryTypes>
<DataSource ID="ReferencedDSDiscovery" TypeID="Windows!Microsoft.Windows.TimedPowerShell.DiscoveryProvider">
<IntervalSeconds>43200</IntervalSeconds>
<SyncTime/>
<ScriptName>ReferencedDatasourceDiscovery.ps1</ScriptName>
<ScriptBody><Script> #Read input parameters
param($sourceType, $sourceId, $managedEntityId, [string] $dpmServerName, $pgId)
function DisplayError()
{
param($description, $severity, $errorCode, $exceptionString, $resolutionString)
$evt = new-object System.Diagnostics.EventLog("DPM Alerts");
$evt.Source = "DPM-EM";
$eventSeverity = [System.Diagnostics.EventLogEntryType]::Information;
#severity = 0 is info and severity = 1 is warning
if($severity -eq 1)
{
$eventSeverity = [System.Diagnostics.EventLogEntryType]::Warning;
}
$errString = new-object system.text.stringBuilder
$errString.AppendLine($description)
if($exceptionString -ne $null)
{
$errString.AppendLine()
$errString.AppendLine("Problem: " + $exceptionString)
}
if($resolutionString -ne $null)
{
$errString.AppendLine()
$errString.AppendLine("Resolution: " + $resolutionString)
}
$evt.WriteEntry($errString.ToString(), $eventSeverity, $errorCode);
}
#######################################################################################
## This script discovers the Referenced DSes
#######################################################################################
$desc = "Referenced DS discovery started event. PgId = " + $pgId
DisplayError $desc 0 124 $null $null
# Load DPM snapin
$dpmBinPath = (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Microsoft Data Protection Manager\Setup" "UIInstallPath").UIInstallPath
. "$dpmBinPath\GlobalFunctions.ps1"
LoadDPMSnapin
#Create and Instantinate SCOM discovery objects
$api = New-Object -ComObject 'MOM.ScriptAPI'
$discoveryData = $api.CreateDiscoveryData($sourceType, $sourceId, $managedEntityId)
try
{
$guid_pgId = [GUID]$pgId
#Connect to DPM server
$err = $($dpmServer = Connect-DPMServer -DPMServerName $dpmServerName) 2>&1
if (!$dpmServer)
{
$desc = "Referenced DS discovery exited event as could not connect to dpm server = " + $dpmServerName
if($err)
{
DisplayError $desc 1 125 $err.Exception.ToString() $err.Exception.Error.Resolution.ToString()
}
else
{
DisplayError $desc 1 125 $null $null
}
exit 1
}
#Get PG object for which we want to discover referenced DSes
$err = $($pg = Get-ProtectionGroup -DPMServerName $dpmServerName | Where{($_.ProtectionGroupId -eq $guid_pgId)}) 2>&1
if($err)
{
$desc = "Unable to retrieve PG list in Referenced DS discovery"
DisplayError $desc 1 125 $err.Exception.ToString() $err.Exception.Error.Resolution.ToString()
}
if($pg)
{
#Get all Referential DSes for the PG
$err = $($dsList = @(Get-Datasource -ProtectionGroup $pg | Where{($_.IsReferentialDatasource)})) 2>&1
if($err)
{
$desc = "Unable to retrieve referential datasource list in Referenced DS discovery"
DisplayError $desc 1 125 $err.Exception.ToString() $err.Exception.Error.Resolution.ToString()
}
if($dsList)
{
$dsList = $dsList | Sort-Object $_.Name
}
if($dsList)
{
foreach($referentialDS in $dsList)
{
foreach($ds in $referentialDS.ReferencedDataSourceCollection)
{
$dsInstance = $null;
$dsInstance = $discoveryData.CreateClassInstance('$MPElement[Name="SCDPM!Microsoft.SystemCenter.DataProtectionManager.2011.Library.ReferencedDatasource"]$');
#set other properties of ds
$dsInstance.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", $dpmServerName)
$dsInstance.AddProperty("$MPElement[Name='SCDPM!Microsoft.SystemCenter.DataProtectionManager.2011.Library.DPMSeed']/DPMServerName$", $dpmServerName)
$dsInstance.AddProperty("$MPElement[Name='SCDPM!Microsoft.SystemCenter.DataProtectionManager.2011.Library.DPMServer']/DPMServerName$", $dpmServerName)
$dsInstance.AddProperty("$MPElement[Name='SCDPM!Microsoft.SystemCenter.DataProtectionManager.2011.Library.ProtectionGroup']/DPMObjectID$", $pgId)
$dsInstance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $ds.DisplayPath)
$dsInstance.AddProperty("$MPElement[Name='SCDPM!Microsoft.SystemCenter.DataProtectionManager.2011.Library.ReferencedDatasource']/DPMServerName$", $dpmServerName)
$dsInstance.AddProperty("$MPElement[Name='SCDPM!Microsoft.SystemCenter.DataProtectionManager.2011.Library.ReferencedDatasource']/PGName$", $ds.ProtectionGroupName)
$dsInstance.AddProperty("$MPElement[Name='SCDPM!Microsoft.SystemCenter.DataProtectionManager.2011.Library.ReferencedDatasource']/PSName$", $ds.ProductionServerName)
$dsInstance.AddProperty("$MPElement[Name='SCDPM!Microsoft.SystemCenter.DataProtectionManager.2011.Library.ReferencedDatasource']/DPMObjectID$", $ds.DatasourceId.ToString())
$dsInstance.AddProperty("$MPElement[Name='SCDPM!Microsoft.SystemCenter.DataProtectionManager.2011.Library.ReferencedDatasource']/IsSecondaryProtected$", $ds.IsDPMDatasource)
$dsInstance.AddProperty("$MPElement[Name='SCDPM!Microsoft.SystemCenter.DataProtectionManager.2011.Library.ReferencedDatasource']/DatasourceType$", $ds.Type.Name)
$dsInstance.AddProperty("$MPElement[Name='SCDPM!Microsoft.SystemCenter.DataProtectionManager.2011.Library.ReferencedDatasource']/SourceDPM$", $ds.SourceDPMServer)
$dsInstance.AddProperty("$MPElement[Name='SCDPM!Microsoft.SystemCenter.DataProtectionManager.2011.Library.ReferencedDatasource']/ReferentialDatasourceId$", $ds.ReferentialDatasourceId.ToString())
$discoveryData.AddInstance($dsInstance)
Remove-Variable dsInstance -Confirm:$false
}
}
}
}
}
catch
{
$desc = "Exception in Referenced DS discovery"
DisplayError $desc 1 125 $_.ToString() $null
throw $_
}
$desc = "Referenced DS discovery completed event. PgId = " + $pgId
DisplayError $desc 0 125 $null $null
#return discovery data
$discoveryData
#Cleanup Variables
Remove-Variable sourceType -Confirm:$false
Remove-Variable sourceId -Confirm:$false
Remove-Variable managedEntityId -Confirm:$false
Remove-Variable discoveryData -Confirm:$false
Remove-Variable api -Confirm:$false
</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>DPMServerName</Name>
<Value>$Target/Property[Type="SCDPM!Microsoft.SystemCenter.DataProtectionManager.2011.Library.ProtectionGroup"]/DPMServerName$</Value>
</Parameter>
<Parameter>
<Name>PgId</Name>
<Value>$Target/Property[Type="SCDPM!Microsoft.SystemCenter.DataProtectionManager.2011.Library.ProtectionGroup"]/DPMObjectID$</Value>
</Parameter>
</Parameters>
<TimeoutSeconds>7200</TimeoutSeconds>
</DataSource>
</Discovery>