Updated for vRops token based auth here

So I needed to automatically run an oversized VM report on a few vRops environments and combine them into one report.

This isn’t my full script as I take the csv and combine is with other data from other metadata, database..etc… but hopefully the following example script / function might help you… It executes the report via the suite-api, waits for it to finish and downloads the csv to a local folder.

First things first… update line 15 in the example script below with your own vRops server IP or FQDN.

$vRopsAddress = 'vc.vman.local'

So that I don’t keep being prompted for credentials I save the service account user and password with the powershell Get-Credential command.

$cred = Get-Credential
$cred | Export-Clixml -Path "d:\vRops\Config\vc.xml"

Once you have generated the XML update line 16 to reflect your *.XML file

$vRopsCreds = Import-Clixml -Path "$ScriptPath\config\VC.xml"

Now that we got that out of the way… we need to obtain the ResourceID for the object / level we wish to run the report for, in my case i want to run it for the whole VC so the easiest way to find the ResourceID for the VC is to use the vRops GUI, search for the VC and get the ResourceID from the URL.


Go to line 17 in the code below and update it to match your ResourceID

$vCenter = '7d3a8453-6559-4d4c-9005-3f8655e4394f'

Now we need to do something similar for the Report that the script will run… So in the vRops GUI, navigate to Content, Reports, Click on Generated Reports


Once you click on Generated Reports you will notice that the URL now has an ID for the Report


Go to line 18 in the code below and update it to match the Report ID

$Report = '1f69952f-7ff4-4d2c-9446-81a811de19b0'

if you found this post useful please consider checking out one of the sponsored links to keep the site running…

full script below…


    The following command must be run once to generate the Credential file to connect to each environment.

        Run once for per virtual center 
        $cred = Get-Credential
        $cred | Export-Clixml -Path "c:\vRops\Config\vc.xml"


$ScriptPath = (Get-Item -Path ".\" -Verbose).FullName
$Output = $ScriptPath  +'\Reports\'
$vRopsAddress = 'vc.vman.local'
$vRopsCreds = Import-Clixml -Path "$ScriptPath\config\VC.xml"
$vCenter = '7d3a8453-6559-4d4c-9005-3f8655e4394f'
$Report = '1f66552f-7bb4-4d2c-9661-81a811de19b0'

## Function

Function GetReport([String]$vRopsAddress, [String]$vCenter, [String]$Report, [String]$Env, $vRopsCreds, $Path){

Write-host 'Running Report for' $Env

#Take all certs.
add-type @"
    using System.Net;
    using System.Security.Cryptography.X509Certificates;
    public class TrustAllCertsPolicy : ICertificatePolicy {
        public bool CheckValidationResult(
            ServicePoint srvPoint, X509Certificate certificate,
            WebRequest request, int certificateProblem) {
            return true;
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy

#RUN Report

$ContentType = "application/xml;charset=utf-8"
$header = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$header.Add("Accept", 'application/xml')

$RunReporturl = 'https://'+$vRopsAddress+'/suite-api/api/reports'

$Body = @"
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ops:report xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ops="http://webservice.vmware.com/vRealizeOpsMgr/1.0/">
    <ops:traversalSpec adapterInstanceAssociation="false">
        <ops:name>vSphere Hosts and Clusters</ops:name>
        <ops:rootResourceKindKey>vSphere World</ops:rootResourceKindKey>

[xml]$Data = Invoke-RestMethod -Method POST -uri $RunReporturl -Credential $vRopsCreds -ContentType $ContentType -Headers $header -Body $body

$ReportLink = $Data.report.links.link.href

$ReportLinkurl = 'https://' + $vRopsAddress + $ReportLink

#Check if report is run to download

[xml]$ReportStatus = Invoke-RestMethod -Method GET -uri $ReportLinkurl -Credential $vRopsCreds -ContentType $ContentType -Headers $header

While ($ReportStatus.report.status -ne "COMPLETED") {
    [xml]$ReportStatus = Invoke-RestMethod -Method GET -uri $ReportLinkurl -Credential $vRopsCreds -ContentType $ContentType -Headers $header
    Write-host 'Waiting for' $Env 'report to finish running, current status: '  $ReportStatus.report.status
    Sleep 3
      } # End of block statement

$ReportDownload = $ReportLinkurl + '/download?format=CSV'

$ReportOutputfile = $Path + '\collections\' + $Env + '_OversizedVMReport.csv'

Invoke-RestMethod -Method GET -uri $ReportDownload -Credential $vRopsCreds -ContentType $ContentType -Headers $header -OutFile $ReportOutputfile

Write-host 'Report for' $Env 'finished'

return $ReportOutputfile

$Report = GetReport $vRopsAddress $vCenter $Report 'VC' $vRopsCreds $ScriptPath