So this post is to help someone over at the vRops vmware communities, they wanted to dump all reports from vRops via the Suite-API so i wrote them a little script to help them on their way… used in conjunction with my first post vrops-suite-api-run-report they will be able to automatically generate all the reports as they please.

 

reportdefinitions

param
(
    [String]$vRopsAddress = 'vc.vman.ch',
    [String]$vRopscreds = 'vc'
)


$ScriptPath = (Get-Item -Path ".\" -Verbose).FullName

if($vRopscreds -gt ""){

    $vRopscred = Import-Clixml -Path "$ScriptPath\config\$vRopscreds.xml"
    }
    else
    {
    echo "crednetials missing"
    Exit
}


#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



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

$url = "https://$vRopsAddress/suite-api/api/reportdefinitions"

[xml]$Data = Invoke-RestMethod -Method GET -uri $url -ContentType $ContentType -Headers $header -Body $body -Credential $vRopscred


$ReportList = @()

Foreach($Report in $Data.'report-definitions'.'report-definition'){

$ReportList += New-Object PsObject -Property @{



        Name = $Report.name
        id = $Report.id
        description = $Report.description
        'traversal-spec-name' = [string]$Report.'traversal-specs'.'traversal-spec'.'name'
        'rootAdapterKindKey' = [string]$Report.'traversal-specs'.'traversal-spec'.'rootAdapterKindKey'
        'rootResourceKindKey' = [string]$Report.'traversal-specs'.'traversal-spec'.'rootResourceKindKey'

    }
}

$ReportList | select id,Name,description,traversal-spec-name,rootAdapterKindKey,rootResourceKindKey | Export-Csv 'c:\vrops\reportlist.csv' -NoTypeInformation


Remove-Variable * -ErrorAction SilentlyContinue