DPM Data Discovery

Microsoft.Windows.SystemCenterDPM.DPMDataDiscovery (Discovery)

This script gets all the component details of the discovered Microsoft System Center Data Protection Manager 2007 (DPM) servers.

Knowledge Base article:

Summary

This rule runs a script to identify all DPM servers and lists out the objects on that server. The objects can be protected computers, data sources, drives and libraries.

Element properties:

TargetMicrosoft.Windows.SystemCenterDPM.DPMServer
EnabledTrue
Frequency7200
RemotableFalse

Object Discovery Details:

Discovered Classes and their attribuets:

Member Modules:

ID Module Type TypeId RunAs 
DS DataSource Microsoft.Windows.TimedScript.DiscoveryProvider Default

Source Code:

<Discovery ID="Microsoft.Windows.SystemCenterDPM.DPMDataDiscovery" Enabled="true" Target="Microsoft.Windows.SystemCenterDPM.DPMServer" ConfirmDelivery="false" Remotable="false" Priority="Normal">
<Category>Discovery</Category>
<DiscoveryTypes>
<DiscoveryClass TypeID="Microsoft.Windows.SystemCenterDPM.ProductionServer">
<Property TypeID="Microsoft.Windows.SystemCenterDPM.ProductionServer" PropertyID="ServerNameLong"/>
</DiscoveryClass>
<DiscoveryClass TypeID="Microsoft.Windows.SystemCenterDPM.DataSource">
<Property TypeID="Microsoft.Windows.SystemCenterDPM.DataSource" PropertyID="DataSourceId"/>
</DiscoveryClass>
<DiscoveryClass TypeID="Microsoft.Windows.SystemCenterDPM.Disk">
<Property TypeID="Microsoft.Windows.SystemCenterDPM.Disk" PropertyID="DiskId"/>
</DiscoveryClass>
<DiscoveryClass TypeID="Microsoft.Windows.SystemCenterDPM.Library">
<Property TypeID="Microsoft.Windows.SystemCenterDPM.Library" PropertyID="LibraryId"/>
</DiscoveryClass>
<DiscoveryClass TypeID="Microsoft.Windows.SystemCenterDPM.Drive">
<Property TypeID="Microsoft.Windows.SystemCenterDPM.Drive" PropertyID="DriveId"/>
</DiscoveryClass>
</DiscoveryTypes>
<DataSource ID="DS" TypeID="Windows!Microsoft.Windows.TimedScript.DiscoveryProvider">
<IntervalSeconds>7200</IntervalSeconds>
<SyncTime/>
<ScriptName>DPMDataDiscovery.vbs</ScriptName>
<Arguments>0 $MPElement$ $Target/Id$ $Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName$</Arguments>
<ScriptBody><Script>'*****************************************************************************
' Author - SatyaY
' Date - 24 December 2007
' Purpose - Script to get the DPM Server data - PS, DS, Disk and Library
'*****************************************************************************

Set oAPI = CreateObject("MOM.ScriptAPI")
Set oArgs = WScript.Arguments

if oArgs.Count &lt; 4 Then
call oAPI.LogScriptEvent("DPMDataDiscovery", 12, 1, "Expected 4 arguments. There were only " &amp; oArgs.Count &amp; " arguments. Exiting script.")
Wscript.Quit -1
End If

SourceType = oArgs(0)
SourceId = oArgs(1)
ManagedEntityId = oArgs(2)
TargetComputer = oArgs(3)

Set oDiscData = oAPI.CreateDiscoveryData(SourceType, SourceId, ManagedEntityId)

'************************************************
' Creating temporary PS file to generate the data
'************************************************
Dim objShell
Set objShell=CreateObject("WScript.Shell")

'enter the PowerShell expression
'you need to use short filenames and paths


sysdrv=objShell.ExpandEnvironmentStrings("%temp%")

Dim objFSO, objFolder, objTextFile, objFile
Dim strDirectory, strFile, strText, psfile, strNewGuid

set x = createobject("Scriptlet.TypeLib")
strNewGuid=left(x.GUID,37)
strNewGuid=Right(strNewGuid,36)

strDirectory = sysdrv + "\dpm_mom" + strNewGuid
strFile = "\GetDPMData.ps1"

' Create the File System Object
Set objFSO = CreateObject("Scripting.FileSystemObject")

' Check that the strDirectory folder exists
If objFSO.FolderExists(strDirectory) Then
Set objFolder = objFSO.GetFolder(strDirectory)
Else
Set objFolder = objFSO.CreateFolder(strDirectory)
End If

If objFSO.FileExists(strDirectory &amp; strFile) Then
Set objFolder = objFSO.GetFolder(strDirectory)
Else
Set objFile = objFSO.CreateTextFile(strDirectory &amp; strFile)
End If

'***************************************************
' Get DPM install path to launch the powershell
'***************************************************

Dim dpmShellPath
const HKEY_LOCAL_MACHINE = &amp;H80000002
strComputer = "."

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &amp;_
strComputer &amp; "\root\default:StdRegProv")

strKeyPath = "SOFTWARE\Microsoft\Microsoft Data Protection Manager\Setup"
strValueName = "InstallPath"
oReg.GetExpandedStringValue HKEY_LOCAL_MACHINE,strKeyPath,_
strValueName,strValue

dpmShellPath = """" &amp; strValue &amp; "bin\dpmshell.psc1" &amp; """"
'MsgBox "The DPM InstallPath is: " &amp; strValue




'*********************************************************
' Generating the ps1 file to get the data from powershell
'**********************************************************

set objFile = Nothing
set objFolder = Nothing

strText="$xmlfilepath = """ + strDirectory + """" &amp;_
Chr(10) &amp; "$dpmServerName = $env:computername " &amp;_
Chr(10) &amp; "$dpmServer = Connect-DPMServer $dpmServerName " &amp;_
Chr(10) &amp; "if (!$dpmServer) " &amp;_
Chr(10) &amp; "{ " &amp;_
Chr(10) &amp; " Write-Error ""Unable to connect to $dpmServerName"" " &amp;_
Chr(10) &amp; " exit 1 " &amp;_
Chr(10) &amp; "} " &amp;_
Chr(10) &amp; "$dpmversion = $dpmServer.GetProductInformation().Version.ToString() " &amp;_
Chr(10) &amp; "$pslist = @(get-productionserver -dpmservername $dpmServerName | ?{$_.ServerProtectionState -ine ""Deleted""}) " &amp;_
Chr(10) &amp; "$liblist = Get-DPMLibrary -dpmservername $dpmServerName | ?{!$_.IsOffline -or $_.ProtectionGroups -ine """" } " &amp;_
Chr(10) &amp; "$disklist = Get-DPMDisk -dpmservername $dpmServerName | ?{$_.IsInStoragePool}" &amp;_
Chr(10) &amp; "$xml = ""&lt;DPM PrincipalName=""""$($dpmServer.Name)"""" " &amp;_
Chr(10) &amp; " NetbiosDomainName=""""$($dpmServer.Domain)"""" " &amp;_
Chr(10) &amp; " NetbiosComputerName=""""$($dpmServerName)"""" " &amp;_
Chr(10) &amp; " DPMVersion=""""$($dpmversion)"""" " &amp;_
Chr(10) &amp; " ProductionServerCount=""""$($pslist.count)""""&gt;`n"" " &amp;_
Chr(10) &amp; "$xml += ""&lt;PSList&gt;`n"" " &amp;_
Chr(10) &amp; "foreach ($ps in $pslist) " &amp;_
Chr(10) &amp; "{ " &amp;_
Chr(10) &amp; " if($ps) "&amp;_
Chr(10) &amp; "{ "&amp;_
Chr(10) &amp; " $dslist = @(Get-Datasource -productionserver $ps | ? {$_.Protected}) " &amp;_
Chr(10) &amp; " $xml += ""&lt;PS DisplayName=""""$($ps.MachineName)"""" " &amp;_
Chr(10) &amp; " ServerNameLong=""""$($ps.Name)"""" " &amp;_
Chr(10) &amp; " DomainName=""""$($ps.DomainName)"""" " &amp;_
Chr(10) &amp; " ClusterName=""""$($ps.ClusterName)"""" " &amp;_
Chr(10) &amp; " ProtectedBy=""""$($dpmServer.Name)"""" " &amp;_
Chr(10) &amp; " DataSourceCount=""""$($dslist.count)"""" &gt;`n"" " &amp;_
Chr(10) &amp; " $xml += ""&lt;DSList&gt;`n"" " &amp;_
Chr(10) &amp; " if($dslist) " &amp;_
Chr(10) &amp; " { " &amp;_
Chr(10) &amp; " foreach($ds in $dslist) " &amp;_
Chr(10) &amp; " { " &amp;_
Chr(10) &amp; " if($ds) "&amp;_
Chr(10) &amp; " { "&amp;_
Chr(10) &amp; " $pg = Get-ProtectionGroup $dpmServerName | ?{$_.Protectiongroupid -eq $ds.ProtectionGroupId} "&amp;_
Chr(10) &amp; " $ProtectionType = $pg.ProtectionMethod "&amp;_
Chr(10) &amp; " $replicasize = ""{0:F2}"" -f ($ds.ReplicaSize / (1024 * 1024 * 1024)) "&amp;_
Chr(10) &amp; " $replicasize = [system.string]$replicasize + "" GB"" "&amp;_
Chr(10) &amp; " $replicavolumeused = ""{0:F2}"" -f ($ds.ReplicaUsedSpace / (1024 * 1024 * 1024)) "&amp;_
Chr(10) &amp; " $replicavolumeused = [system.string]$replicavolumeused + "" GB"" "&amp;_
Chr(10) &amp; " $recoverypointsize = ""{0:F2}"" -f ($ds.ShadowCopyAreaSize / (1024 * 1024 * 1024)) "&amp;_
Chr(10) &amp; " $recoverypointsize = [system.string]$recoverypointsize + "" GB"" "&amp;_
Chr(10) &amp; " $recoverypointvolumeused = ""{0:F2}"" -f ($ds.ShadowCopyUsedSpace / (1024 * 1024 * 1024)) "&amp;_
Chr(10) &amp; " $recoverypointvolumeused = [system.string]$recoverypointvolumeused + "" GB"" "&amp;_
Chr(10) &amp; " $polong = Get-PolicyObjective -ProtectionGroup $pg -longterm "&amp;_
Chr(10) &amp; " $poshort = Get-PolicyObjective -ProtectionGroup $pg -shortterm "&amp;_
Chr(10) &amp; " $sync = """" "&amp;_
Chr(10) &amp; " $shortpolicy = """" "&amp;_
Chr(10) &amp; " $longpolicy = """" "&amp;_
Chr(10) &amp; " if($poshort) "&amp;_
Chr(10) &amp; " { "&amp;_
Chr(10) &amp; " $st = $poshort.schedules "&amp;_
Chr(10) &amp; " $sync = $st[0] "&amp;_
Chr(10) &amp; " $shortpolicy = $poshort.RecoveryRange.ToString() + ""|"" + $sync.ToString() + "" synchronization"" "&amp;_
Chr(10) &amp; " } "&amp;_
Chr(10) &amp; " if($polong) "&amp;_
Chr(10) &amp; " { "&amp;_
Chr(10) &amp; " $longpolicy = $polong.RecoveryRange.ToString() + ""|Backup frequency - "" + $polong.frequency.ToString() "&amp;_
Chr(10) &amp; " } "&amp;_
Chr(10) &amp; " $xml += ""&lt;DS FullServerName=""""$($ds.ProductionServerName)"""" " &amp;_
Chr(10) &amp; " DisplayName=""""$($ps.MachineName)"""" " &amp;_
Chr(10) &amp; " ProtectedBy=""""$($dpmServer.Name)"""" " &amp;_
Chr(10) &amp; " DomainName=""""$($ds.PSInfo.DomainName)"""" " &amp;_
Chr(10) &amp; " ProtectionGroup=""""$($ds.ProtectionGroupName)"""" " &amp;_
Chr(10) &amp; " ProtectionType=""""$($ProtectionType)"""" " &amp;_
Chr(10) &amp; " ReplicaSize=""""$($replicasize)"""" " &amp;_
Chr(10) &amp; " DataSourceType=""""$($ds.ToString(""""T"""", $null))"""" " &amp;_
Chr(10) &amp; " DataSourceName=""""$($ds.Name)"""" " &amp;_
Chr(10) &amp; " RecoveryPointCount=""""$($ds.TotalRecoveryPoints)"""" " &amp;_
Chr(10) &amp; " RecoveryPointVolume=""""$($recoverypointvolumeused)"""" " &amp;_
Chr(10) &amp; " RecoveryPointSize=""""$($recoverypointsize)"""" " &amp;_
Chr(10) &amp; " ReplicaVolume=""""$($replicavolumeused)"""" " &amp;_
Chr(10) &amp; " ShortBackupPolicy=""""$($shortpolicy)"""" " &amp;_
Chr(10) &amp; " LongBackupPolicy=""""$($longpolicy)"""" " &amp;_
Chr(10) &amp; " DataSourceId=""""$($ds.DatasourceId.ToString())"""" /&gt;`n"" " &amp;_
Chr(10) &amp;" }"&amp;_
Chr(10) &amp; " } " &amp;_
Chr(10) &amp; " } " &amp;_
Chr(10) &amp; " $xml += ""&lt;/DSList&gt;`n"" " &amp;_
Chr(10) &amp; " $xml += ""&lt;/PS&gt;`n"" " &amp;_
Chr(10) &amp; "} "&amp;_
Chr(10) &amp; "} " &amp;_
Chr(10) &amp; "$xml += ""&lt;/PSList&gt;`n"" " &amp;_
Chr(10) &amp; "$xml += ""&lt;DiskList&gt;`n"" " &amp;_
Chr(10) &amp; "foreach ($disk in $disklist) " &amp;_
Chr(10) &amp; "{ " &amp;_
Chr(10) &amp; " if($disk) "&amp;_
Chr(10) &amp; "{ "&amp;_
Chr(10) &amp; " $allocated = $disk.TotalCapacity - $disk.UnallocatedSpace " &amp;_
Chr(10) &amp; " $percentallocated = ""{0:F2}"" -f (100 * $allocated / $disk.TotalCapacity) " &amp;_
Chr(10) &amp; " $dispName = ""Disk"" + $disk.NtDiskID + ""("" + $disk.Name + "")"" " &amp;_
Chr(10) &amp; " $percentunallocated = ""{0:F2}"" -f (100 - $percentallocated) " &amp;_
Chr(10) &amp; " $allocated = ""{0:F2}"" -f ($allocated / (1024 * 1024 * 1024)) " &amp;_
Chr(10) &amp; " $allocated = [system.string]$allocated + "" GB"" " &amp;_
Chr(10) &amp; " $Unallocated = ""{0:F2}"" -f ($disk.UnallocatedSpace / (1024 * 1024 * 1024)) " &amp;_
Chr(10) &amp; " $Unallocated = [system.string]$Unallocated + "" GB"" " &amp;_
Chr(10) &amp; " $disksize = ""{0:F2}"" -f ($disk.TotalCapacity / (1024 * 1024 * 1024)) " &amp;_
Chr(10) &amp; " $disksize = [system.string]$disksize + "" GB"" " &amp;_
Chr(10) &amp; " $xml += ""&lt;Disk DiskId=""""$($disk.Identifier.ToString())"""" " &amp;_
Chr(10) &amp; " DiskName=""""$($disk.Name)"""" " &amp;_
Chr(10) &amp; " DiskType=""""$($disk.GetType().Name)"""" " &amp;_
Chr(10) &amp; " DPMServerName=""""$($disk.DPMServerName)"""" " &amp;_
Chr(10) &amp; " DiskSize=""""$($disksize)"""" " &amp;_
Chr(10) &amp; " UnallocatedSize=""""$($Unallocated)"""" " &amp;_
Chr(10) &amp; " AllocatedSize=""""$($allocated)"""" " &amp;_
Chr(10) &amp; " PercentAllocated=""""$($percentallocated)"""" " &amp;_
Chr(10) &amp; " DisplayName=""""$($dispName)"""" " &amp;_
Chr(10) &amp; " PercentUnallocated=""""$($percentunallocated)"""" /&gt;`n"" " &amp;_
Chr(10) &amp; "} "&amp;_
Chr(10) &amp; "} " &amp;_
Chr(10) &amp; "$xml += ""&lt;/DiskList&gt;`n"" " &amp;_
Chr(10) &amp; "$xml += ""&lt;LibList&gt;`n"" " &amp;_
Chr(10) &amp; "foreach ($lib in $liblist) " &amp;_
Chr(10) &amp; "{ " &amp;_
Chr(10) &amp; " if($lib) "&amp;_
Chr(10) &amp; "{ "&amp;_
Chr(10) &amp; " $drivelist = $lib.GetDriveCollection() " &amp;_
Chr(10) &amp; " $mediacollection = $lib.GetMediaCollection() " &amp;_
Chr(10) &amp; " $tapeDriveCount = 0 " &amp;_
Chr(10) &amp; " $tapeslots = 0 " &amp;_
Chr(10) &amp; " foreach($media in $mediacollection) " &amp;_
Chr(10) &amp; " { " &amp;_
Chr(10) &amp; " if($media.Location.Name -eq ""Drive"") " &amp;_
Chr(10) &amp; " { " &amp;_
Chr(10) &amp; " $tapeDriveCount++ " &amp;_
Chr(10) &amp; " } elseif($media.Location.Name -ieq ""slot"") " &amp;_
Chr(10) &amp; " { " &amp;_
Chr(10) &amp; " $tapeslots++ " &amp;_
Chr(10) &amp; " } " &amp;_
Chr(10) &amp; " } " &amp;_
Chr(10) &amp; " $slotsCount = $lib.GetSlotCollection().Count " &amp;_
Chr(10) &amp; " $freeslots = $slotsCount - $tapeslots " &amp;_
Chr(10) &amp; " $freedrives = $lib.GetDriveCollection().Count - $tapeDriveCount " &amp;_
Chr(10) &amp; " $xml += ""&lt;Lib LibraryId=""""$($lib.Id.ToString())"""" " &amp;_
Chr(10) &amp; " LibraryType=""""$($lib.Type)"""" " &amp;_
Chr(10) &amp; " DPMServerName=""""$($lib.MachineName)"""" " &amp;_
Chr(10) &amp; " SlotsCount=""""$($slotsCount)"""" " &amp;_
Chr(10) &amp; " TapesCount=""""$($lib.GetMediaCollection().Count)"""" " &amp;_
Chr(10) &amp; " DriveCount=""""$($lib.GetDriveCollection().Count)"""" " &amp;_
Chr(10) &amp; " FreeSlotsCount=""""$($freeslots)"""" " &amp;_
Chr(10) &amp; " TapeSlotsCount=""""$($tapeslots)"""" " &amp;_
Chr(10) &amp; " FreeDriveCount=""""$($freedrives)"""" " &amp;_
Chr(10) &amp; " DisplayName=""""$($lib.UserFriendlyName)"""" &gt;`n"" " &amp;_
Chr(10) &amp; " $xml += ""&lt;DriveList&gt;`n"" " &amp;_
Chr(10) &amp; " if($drivelist) " &amp;_
Chr(10) &amp; " { " &amp;_
Chr(10) &amp; " foreach($drive in $drivelist) " &amp;_
Chr(10) &amp; " { " &amp;_
Chr(10) &amp; " if($drive) "&amp;_
Chr(10) &amp; " { "&amp;_
Chr(10) &amp; " $scsiid = ""Port:"" + $drive.SCSIPort + "" Bus:"" + $drive.SCSIBus + "" Target:"" + $drive.SCSITargetId + "" Lun:"" + $drive.SCSILun "&amp;_
Chr(10) &amp; " $readerrors = ""Critical:"" + $drive.HardReadErrors + ""|"" + ""Transient:"" + $drive.SoftReadErrors "&amp;_
Chr(10) &amp; " $writeerrors = ""Critical:"" + $drive.HardWriteErrors + ""|"" + ""Transient:"" + $drive.SoftWriteErrors "&amp;_
Chr(10) &amp; " $xml += ""&lt;Drive DriveId=""""$($drive.Id.ToString())"""" " &amp;_
Chr(10) &amp; " DriveName=""""$($drive.ProductId)"""" " &amp;_
Chr(10) &amp; " DriveStatus=""""$($drive.Status)"""" " &amp;_
Chr(10) &amp; " LibraryName=""""$($drive.LibraryName)"""" " &amp;_
Chr(10) &amp; " DPMServerName=""""$($dpmServerName)"""" " &amp;_
Chr(10) &amp; " DriveSerialNumber=""""$($drive.SerialNumber)"""" " &amp;_
Chr(10) &amp; " DriveType=""""$($drive.MediaTypesSupported)"""" " &amp;_
Chr(10) &amp; " WindowsDriveName=""""$($drive.AccessPath)"""" " &amp;_
Chr(10) &amp; " SCSIID=""""$($scsiid)"""" " &amp;_
Chr(10) &amp; " LastCleaned=""""$($drive.LastCleaningDate.ToString())"""" " &amp;_
Chr(10) &amp; " ReadErrorsSinceLastCleaned=""""$($readerrors)"""" " &amp;_
Chr(10) &amp; " WriteErrorsSinceLastCleaned=""""$($writeerrors)"""" /&gt;`n"" " &amp;_
Chr(10) &amp; " }"&amp;_
Chr(10) &amp; " } " &amp;_
Chr(10) &amp; " } " &amp;_
Chr(10) &amp; " $xml += ""&lt;/DriveList&gt;`n"" " &amp;_
Chr(10) &amp; " $xml += ""&lt;/Lib&gt;`n"" " &amp;_
Chr(10) &amp; " }" &amp;_
Chr(10) &amp; "} " &amp;_
Chr(10) &amp; "Disconnect-DPMServer " &amp;_
Chr(10) &amp; "$xml += ""&lt;/LibList&gt;`n"" " &amp;_
Chr(10) &amp; "$xml += ""&lt;/DPM&gt;`n"" " &amp;_
Chr(10) &amp; "$xmlfile = [xml] $xml " &amp;_
Chr(10) &amp; "$xmlfile.save((Join-path $xmlfilepath ""DPMDiscoveryData.xml""))"


' ForAppending = 8 ForReading = 1, ForWriting = 2
Const ForAppending = 8
Const ForWriting = 2

Set objTextFile = objFSO.OpenTextFile _
(strDirectory &amp; strFile, ForWriting, True)

' Writes strText every time you run this VBScript
objTextFile.WriteLine(strText)
objTextFile.Close

psfile = strDirectory &amp; strFile


strCMD="powershell -PSConsoleFile " &amp; dpmShellPath &amp; " -nologo -command " &amp; psfile
'Uncomment next line for debugging
'MsgBox("strCMD: " &amp; strCMD)

'use 0 to hide window
objShell.Run strCMD,0,true


'***********************************************************************************
' Reading the xml file generated from PS script and creating the MOM objects
'***********************************************************************************

set xmlDoc=CreateObject("Microsoft.XMLDOM")
xmlDoc.async="false"
xmlDoc.load(strDirectory &amp; "\DPMDiscoveryData.xml")

Set root = xmlDoc.documentElement

Set oDPMInst = oDiscData.CreateClassInstance("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.DPMServer"]$")

call oDPMInst.AddProperty("$MPElement[Name="Windows!Microsoft.Windows.Computer"]/PrincipalName$", TargetComputer)
call oDPMInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.DPMServer"]/ProductionServerCount$", root.getAttribute("ProductionServerCount"))
call oDPMInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.DPMServer"]/DPMVersion$", root.getAttribute("DPMVersion"))
call oDiscData.AddInstance(oDPMInst)

set pslist = root.firstchild

For each ps in pslist.childnodes

Set oInst = oDiscData.CreateClassInstance("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.ProductionServer"]$")

call oInst.AddProperty("$MPElement[Name="Windows!Microsoft.Windows.Computer"]/PrincipalName$", TargetComputer)
call oInst.AddProperty("$MPElement[Name="System!System.Entity"]/DisplayName$",ps.getAttribute("DisplayName"))
call oInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.ProductionServer"]/ServerNameLong$", ps.getAttribute("ServerNameLong"))
call oInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.ProductionServer"]/DomainName$", ps.getAttribute("DomainName"))
call oInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.ProductionServer"]/ClusterName$", ps.getAttribute("ClusterName"))
call oInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.ProductionServer"]/ProtectedBy$", ps.getAttribute("ProtectedBy"))
call oInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.ProductionServer"]/DataSourceCount$", ps.getAttribute("DataSourceCount"))
call oDiscData.AddInstance(oInst)


set dslist = ps.firstchild
Dim datasoure, isValidDS

For each ds in dslist.childnodes

dstype = ds.getAttribute("DataSourceType")
isValidDS = false
if Instr(LCase(dstype),"volume") then
Set oInst = oDiscData.CreateClassInstance("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.VolumeDataSource"]$")
call oInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.VolumeDataSource"]/DataSourceType$", ds.getAttribute("DataSourceType"))
isValidDS = True
elseif Instr(LCase(dstype),"sql")then
Set oInst = oDiscData.CreateClassInstance("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.SQLDBDataSource"]$")
call oInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.SQLDBDataSource"]/DataSourceType$", ds.getAttribute("DataSourceType"))
isValidDS = True
elseif Instr(LCase(dstype),"storage")then
Set oInst = oDiscData.CreateClassInstance("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.ExchangeDataSource"]$")
call oInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.ExchangeDataSource"]/DataSourceType$", ds.getAttribute("DataSourceType"))
isValidDS = True
elseif Instr(LCase(dstype),"sharepoint")then
Set oInst = oDiscData.CreateClassInstance("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.SharePointDataSource"]$")
call oInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.SharePointDataSource"]/DataSourceType$", ds.getAttribute("DataSourceType"))
isValidDS = True
elseif Instr(LCase(dstype),"virtual")then
Set oInst = oDiscData.CreateClassInstance("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.VirtualServerDataSource"]$")
call oInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.VirtualServerDataSource"]/DataSourceType$", ds.getAttribute("DataSourceType"))
isValidDS = True
elseif Instr(LCase(dstype),"system")then
Set oInst = oDiscData.CreateClassInstance("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.SystemStateDataSource"]$")
call oInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.SystemStateDataSource"]/DataSourceType$", ds.getAttribute("DataSourceType"))
isValidDS = True
end if


if isValidDS = false then
Set oInst = oDiscData.CreateClassInstance("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.DataSource"]$")
end if
call oInst.AddProperty("$MPElement[Name="Windows!Microsoft.Windows.Computer"]/PrincipalName$", TargetComputer)
call oInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.ProductionServer"]/ServerNameLong$", ps.getAttribute("ServerNameLong"))
call oInst.AddProperty("$MPElement[Name="System!System.Entity"]/DisplayName$",ds.getAttribute("DataSourceName"))
call oInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.DataSource"]/FullServerName$", ds.getAttribute("FullServerName"))
call oInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.DataSource"]/ProtectedBy$", ds.getAttribute("ProtectedBy"))
call oInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.DataSource"]/DomainName$", ds.getAttribute("DomainName"))
call oInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.DataSource"]/ProtectionGroup$", ds.getAttribute("ProtectionGroup"))
call oInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.DataSource"]/ReplicaSize$", ds.getAttribute("ReplicaSize"))
call oInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.DataSource"]/DataSourceName$", ds.getAttribute("DataSourceName"))
call oInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.DataSource"]/RecoveryPointCount$", ds.getAttribute("RecoveryPointCount"))
call oInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.DataSource"]/DataSourceId$", ds.getAttribute("DataSourceId"))
call oInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.DataSource"]/ProtectionType$", ds.getAttribute("ProtectionType"))
call oInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.DataSource"]/RecoveryPointVolume$", ds.getAttribute("RecoveryPointVolume"))
call oInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.DataSource"]/RecoveryPointSize$", ds.getAttribute("RecoveryPointSize"))
call oInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.DataSource"]/ReplicaVolume$", ds.getAttribute("ReplicaVolume"))
call oInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.DataSource"]/ShortBackupPolicy$", ds.getAttribute("ShortBackupPolicy"))
call oInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.DataSource"]/LongBackupPolicy$", ds.getAttribute("LongBackupPolicy"))


call oDiscData.AddInstance(oInst)


Next
Next


Set disklist = pslist.nextSibling

For each disk in disklist.childnodes

Set oInst = oDiscData.CreateClassInstance("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.Disk"]$")

call oInst.AddProperty("$MPElement[Name="Windows!Microsoft.Windows.Computer"]/PrincipalName$", TargetComputer)
call oInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.Disk"]/DiskId$", disk.getAttribute("DiskId"))
call oInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.Disk"]/DiskName$", disk.getAttribute("DiskName"))
call oInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.Disk"]/DiskType$", disk.getAttribute("DiskType"))
call oInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.Disk"]/DPMServerName$", disk.getAttribute("DPMServerName"))
call oInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.Disk"]/DiskSize$", disk.getAttribute("DiskSize"))
call oInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.Disk"]/UnallocatedSize$", disk.getAttribute("UnallocatedSize"))
call oInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.Disk"]/AllocatedSize$", disk.getAttribute("AllocatedSize"))
call oInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.Disk"]/PercentAllocated$", disk.getAttribute("PercentAllocated"))
call oInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.Disk"]/PercentUnallocated$", disk.getAttribute("PercentUnallocated"))
call oInst.AddProperty("$MPElement[Name="System!System.Entity"]/DisplayName$",disk.getAttribute("DisplayName"))
call oDiscData.AddInstance(oInst)


Next

Set liblist = disklist.nextSibling

For Each lib In liblist.childnodes

Set oLibInst = oDiscData.CreateClassInstance("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.Library"]$")

call oLibInst.AddProperty("$MPElement[Name="Windows!Microsoft.Windows.Computer"]/PrincipalName$", TargetComputer)
call oLibInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.Library"]/LibraryId$", lib.getAttribute("LibraryId"))
call oLibInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.Library"]/LibraryName$", lib.getAttribute("DisplayName"))
call oLibInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.Library"]/LibraryType$", lib.getAttribute("LibraryType"))
call oLibInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.Library"]/DPMServerName$", lib.getAttribute("DPMServerName"))
call oLibInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.Library"]/SlotsCount$", lib.getAttribute("SlotsCount"))
call oLibInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.Library"]/TapesCount$", lib.getAttribute("TapesCount"))
call oLibInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.Library"]/DriveCount$", lib.getAttribute("DriveCount"))
call oLibInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.Library"]/FreeSlotsCount$", lib.getAttribute("FreeSlotsCount"))
call oLibInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.Library"]/TapeSlotsCount$", lib.getAttribute("TapeSlotsCount"))
call oLibInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.Library"]/FreeDriveCount$", lib.getAttribute("FreeDriveCount"))
call oLibInst.AddProperty("$MPElement[Name="System!System.Entity"]/DisplayName$",lib.getAttribute("DisplayName"))
call oDiscData.AddInstance(oLibInst)


set drivelist = lib.firstchild

For each drive in drivelist.childnodes

Set oInst = oDiscData.CreateClassInstance("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.Drive"]$")

call oInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.Library"]/LibraryId$", lib.getAttribute("LibraryId"))
call oInst.AddProperty("$MPElement[Name="Windows!Microsoft.Windows.Computer"]/PrincipalName$", TargetComputer)
call oInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.Drive"]/DriveId$", drive.getAttribute("DriveId"))
call oInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.Drive"]/DriveName$", drive.getAttribute("DriveName"))
call oInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.Drive"]/DriveStatus$", drive.getAttribute("DriveStatus"))
call oInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.Drive"]/LibraryName$", drive.getAttribute("LibraryName"))
call oInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.Drive"]/DPMServerName$", drive.getAttribute("DPMServerName"))
call oInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.Drive"]/DriveSerialNumber$", drive.getAttribute("DriveSerialNumber"))
call oInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.Drive"]/DriveType$", drive.getAttribute("DriveType"))
call oInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.Drive"]/SCSIID$", drive.getAttribute("SCSIID"))
call oInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.Drive"]/LastCleaned$", drive.getAttribute("LastCleaned"))
call oInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.Drive"]/ReadErrorsSinceLastCleaned$", drive.getAttribute("ReadErrorsSinceLastCleaned"))
call oInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.Drive"]/WriteErrorsSinceLastCleaned$", drive.getAttribute("WriteErrorsSinceLastCleaned"))
call oInst.AddProperty("$MPElement[Name="Microsoft.Windows.SystemCenterDPM.Drive"]/WindowsDriveName$", drive.getAttribute("WindowsDriveName"))
call oInst.AddProperty("$MPElement[Name="System!System.Entity"]/DisplayName$", drive.getAttribute("DriveName"))
call oDiscData.AddInstance(oInst)


Next

Next

' Deleting the temporary files and folders
objFSO.DeleteFolder(strDirectory)

call oAPI.Return(oDiscData)

</Script></ScriptBody>
<TimeoutSeconds>1800</TimeoutSeconds>
</DataSource>
</Discovery>