powershellvirtual-machinevmware

I want to configure a report for specific VM in vrops/aria


I want to configure a report specific to a Virtual Machine. For Example, I want to get the report with below metric for specifc virtual machine in pdf format. Please let me know how this can be achieved?

I also tried using PowerShell, but I'm getting error due to time and date miss match for the various metrics

$resource = 'Server01'
$cred = Get-Credential


try {
    Connect-OMServer "vrops.example.com" -Username $username -Password $password -ErrorAction Stop | Out-Null
    Write-Host "Connected to vROPS server"
}
catch {
    Write-Host "Failed to connect to vROPS server." ($_.Exception.Message)
    exit
}

$today = Get-Date
$last30days = $today.AddDays(-30).

$demandmhz = Get-OMStat -Resource $resource -Key 'cpu|demandmhz' -From $last30days -To $today -ErrorAction Stop
$demandper = Get-OMStat -Resource $resource -Key 'cpu|demandPct' -From $last30days -To $today -ErrorAction Stop
$usageper = Get-OMStat -Resource $resource -Key 'cpu|usage_average' -From $last30days -To $today -ErrorAction Stop
$usagemhz = Get-OMStat -Resource $resource -Key 'cpu|usagemhz_average' -From $last30days -To $today -ErrorAction Stop

$cpu = [PSCustomObject]@{
    Resource = $resource
    DemandMhz = $demandmhz.Value
    DemandPer = $demandper.Value
    UsagePer = $usageper.Value
    UsageMhz = $usagemhz.Value
}

$cpu | Export-Csv -Path "C:\temp\cpu.csv" -NoTypeInformation -Append

I want report for above requirement using powershell or rest api


Solution

  • I have found a way to my question. Link use GET /api/reportdefinitions API to get the Virtual Machine resource ID and use GET /api/reports API to get the reportDefinition ID. Then use POST /api/reports API to trigger the report. And Finally use GET /api/reports/{id}/download API to download the report