VMware Cloud Community

PowerCLI SRM History Report HTML(Like the Web Client Export)

So after we run a SRM Test we are expected to provide the History HTML report. Generally we export that from the web client and that works great but when we have 4 histories per recovery plan and 15+ recovery plans we now start to look at automating this export.

Unfortunately I am not able to find out how to get the XML data of the history report like we get from the web client.  I get this far:

$SRMExtensionData = $SRMConnection.ExtensionData;

$Recovery = $SRMExtensionData.Recovery;

$RecoveryPlans = $SRMExtensionData.Recovery.ListPlans();

foreach ($RecoveryPlan in $RecoveryPlans) {

    $RPHistory = $Recovery.GetHistory($RecoveryPlan.MoRef);

    $RPHistoryCount = $RPHistory.GetResultCount();

    $RPHistoryResults = $RPHistory.GetRecoveryResult($RPHistoryCount);


Each history result only gives me :

Key                      :

Plan                     :

Name                     :

Description              :

StartTime                :

StopTime                 :

ExecutionTimeInSeconds   :

TotalPausedTimeInSeconds :

ResultState              :

RunMode                  :

WarningCount             :

ErrorCount               :

Am I missing someplace else to get this information from or a method to export?

Tags (3)
0 Kudos
5 Replies


I'm having the same issue, but I am needing to export the data in HTML format.  Here is the code I use to get the XML output using your variables:


So, my big problem is how do we get it into HTML format after getting the XML output just like if we were to use the web client.  If you figure that out, please let me know.

0 Kudos


Just wondering if you've been able to convert the XML report to HTML? I've been trying to collect the HTML report for an auditing purpose from 100s of recovery plans (SRM appliance v8.3).

There appears to be an XSL (eXtensible Stylesheet Language) in use to transform the XML to HTML/CSV and I've been able to locate the xsl files in the SRM appliance. The SRM, when using the HTML client should use one of these xsl files to generate the report from the GUI. I tried to use the same xsl to convert one the xml files but didn't work.



0 Kudos

For some reason, I don't see my post. Therefore I'm posting it again and I hope it won't disappear again,

Finally I was able to transform the XML to HTML. I've modified your code that creates the XML file, leverages .Net System.Xml namespace to load the XSL and transform the XML to HTML. As I mentioned earlier, it is the XSL that does the transformation. Although I didn't create a new XSL file myself (which would be a little bit tedious), I used the existing the XSL file that was shipped with the SRM appliance. Let me know if you're interested in testing it.

$credential = Get-Credential

$ErrorActionPreference = 'SilentlyContinue'
$SRMServer          = Connect-SrmServer -Credential $credential -RemoteCredential $credential -Port 443
$SRMExtensionData   = $SRMServer.ExtensionData

$countA = 0
$PlanCount = ($SRMExtensionData.Recovery.ListPlans()).Count

while ($countA -le $PlanCount) {
    $RecoveryPlan   = $SRMExtensionData.Recovery.ListPlans()[$countA].moref
    $RPHistory      = $SRMExtensionData.Recovery.GetHistory($RecoveryPlan)
    $RPHistoryCount = $RPHistory.GetResultCount()

    If ($RPHistoryCount -gt 0) {
        $RPHistoryResults   = $RPHistory.GetRecoveryResult($RPHistoryCount)
        $runCount           = (($RPHistoryResults).key).count
        $countB             = 0

        While ($countB -le $runCount) {
            [System.XML.XMLDocument]$xml=New-Object System.XML.XMLDocument
            $xml = [xml]($RPHistory.RetrieveStatus(($RPHistoryResults[$countB]).key,0, 999999999))
            $xmlFile = [System.String]::Concat($XML.RecoveryPlanResult.RecoveryPlan.Name,"_",$XML.RecoveryPlanResult.Info.Mode,"_",(($XML.RecoveryPlanResult.Info.startTime) -replace ':','_'),".xml")
            $XML.Save("D:\SRM\xml\{0}" -f $xmlFile)
			$htmlFile = [System.String]::Concat($XML.RecoveryPlanResult.RecoveryPlan.Name,"_",$XML.RecoveryPlanResult.Info.Mode,"_",(($XML.RecoveryPlanResult.Info.startTime) -replace ':','_'),".html")
			#-- Create transformation --#
			$xslt = New-Object System.Xml.Xsl.XslCompiledTransform
			#-- Create a reader with DTDparsing set to parse --#
			$xrs = New-Object System.Xml.XmlReaderSettings
			$xrs.DtdProcessing = 'Parse'
			#-- Load the tarsnform with the reader setting --#
			$xsl = 'D:\SRM\RecoveryHistory.xsl'
			$xr = [System.Xml.XmlReader]::Create("$xsl", $xrs)
			#-- Create a writer --#
			$htmlLocation = 'D:\SRM\html'
			$xws = New-Object System.Xml.XmlWriterSettings
			$xw = [System.Xml.XmlWriter]::Create("$htmlLocation\$htmlFile", $xslt.OutputSettings)
			#-- Execute the transform and output the results to the HTML file --#
			$xslt.Transform("D:\SRM\xml\$xmlFile", $xw)




awesome, thank you very much for your efforts! But unfortunately I seem to have some issues replicating your work. The xml files are extracted properly, htmls are created but empty. The xsl seems to be loaded properly but was fetched from SRM 8.4 instances. Were there other changes necessary on the system or xsl to get it working? Can you verify if the xsls from SRM 8.4 are also working for you?

0 Kudos

Ok, it seems we cant use the original XSL File fetched from SRM but need to change it accordingly based on your(?) question on stackoverflow


We need to remove ALL blocks where templates are called based on the output type and only leave the correct lines for outputting html similar to the example provided there.

0 Kudos