I've got a PowerShell script where I'm collecting a bunch of data and then outputting to an HTML report.
One of the sections is the following:
$VPGSummaryInfo = Get-ZertoVPG | Select VPGName, Priority, Status, ProgressPercentage, ActualRPO | Sort-Object -Property VPGName
$htmlbody += $VPGSummaryInfo | ConvertTo-Html -Fragment
Simple enough.
What I'm trying to do and can't figure out, is how to change the Priority to replace the results. For example, when Priority is 1, change that to 'High'.
I tried to do something like this, but it is giving me an error (not in a place to validate, but I believe it was a Null expression error):
$VPGInfo = @()
$VPGStatus = @{
1 = "High"; 2 = "Medium"; 3 = "Low"
}
$VPG = Get-ZertoVPG | Select VPGName, Priority, Status, ProgressPercentage, ActualRPO
$VPGStat = $VPGStatus[[int]$VPG.Priority]
$VPGObj = New-Object PSObject
$VPGObj | Add-Member NoteProperty -Name "VPG Name" -Value $VPG.VPGName
$VPGObj | Add-Member NoteProperty -Name "Priority" -Value $VPGStat
$VPGObj | Add-Member NoteProperty -Name "Status" -Value $VPG.Status
$VPGObj | Add-Member NoteProperty -Name "Replication Progress Percentage (%)" -Value $VPG.ProgressPercentage
$VPGObj | Add-Member NoteProperty -Name "Actual RPO (Sec)" -Value $VPG.ActualRPO
$VPGInfo += $VPGObj
$htmlbody += $VPGInfo | ConvertTo-Html -Fragment
I am completely open to any method to accomplish this. I have a lot of different scenarios where I'm going to need to do similar replacements. For example, even in the code above, I will be trying to replace the Status to something more readable.
Thanks for any suggestions.