22nd May 2020

Adding Virtual Machine advanced settings to custom properties in vRealize Operations

Adding Virtual Machine advanced settings to custom properties in vRealize Operations

I’ve been working with a customer recently that want to display advanced settings from a virtual machine in vRealize Operations manager.  If you didn’t know vROPs does a fantastic job of collecting object settings and presenting them back so they can be tracked in dashboards, views and reports or used for troubleshooting.

But the adaptors don’t collect everything, for example if you create a custom advanced setting on a VM how would vROPs know to collect that information?


vROPs has a comprehensive REST API that includes methods for creating, reading, updating and deleting properties.  The API can be reviewed from any vROPs installation by browsing to ‘https://<vROPS_FQDN>/suite-api/’ . Which includes links off to the documentation.  When reviewing what is possible you will see that I wasn’t joking about it being comprehensive.  A review of what is available lists a ‘Resource/addProperties’ method.


Doing what everybody does I did a quick search of adding properties in using this method and found a great VMware article that calls this method from PowerCLI to add static entries to property fields.  The core of what I’ve pulled together uses the logic described in the article (Thank you to John Dias!) to achieve what we need so give it a read…

…it’s OK I’ll wait for you to finish.

What the article describes and leads through practically are a series of commands required to set a static value to a variable that can be used to populate the data for the API POST to vROPs for one VM object.

The areas I wanted to expand upon are;

  • Allow the Advanced Setting to be set as part of the script and to pull the value from Virtual Center Virtual Machine object
  • Allow the StatKey to be set as part of the script
  • Allow the script to be run against a targeted Cluster
  • Build simple logic to check if the Advanced Setting exists and if it doesn’t to skip
  • Post the value to vRealize Operations Manager


Here’s the code!  Including comments.  Further information and the code is also available on VMware Code and GitHub

#Ask for variable values for Advanced Settings and StatKey
$Advsetting = Read-Host -Prompt "Enter the Virtual Machine advanced setting string exactly as it is listed e.g. tools.guest.desktop.autolock"
$statkey = Read-Host -Promt "Enter the vRealize Operations Manager property location to display the property value e.g. import|desktopAutolock"

#Ask for a VMware Cluster to target 
$allclusters = Get-Cluster
    Write-Host ("$allclusters") -ForegroundColor DarkGreen -BackgroundColor White
$cluster = Read-Host -Prompt "Enter the connected Cluster Name from the list above"

$VMS = Get-VM -location $cluster

#Test to see if Advanced Setting exists and either write out "nothing to do!" or pass to the elements that call the addproperty method
foreach($VM in $VMS){
    $n = ("$($")
    $OMResource = Get-OMResource $n

    $value = Get-AdvancedSetting -Entity $VM -Name $Advsetting -ErrorAction SilentlyContinue
if ($value -eq $null) {
    write-host ("$Advsetting is not set on VC object $VM! Nothing to Do!") -ForegroundColor DarkGreen -BackgroundColor White
else {
    write-host ("$Advsetting is set on VC object $VM! Writing value to vRealize Operations Manager!") -ForegroundColor White -BackgroundColor DarkGreen

    $contentprops = New-Object VMware.VimAutomation.vROps.Views.PropertyContents
    $contentprop = New-Object VMware.VimAutomation.vROps.Views.PropertyContent
        $contentprop.StatKey = ("$($statkey)")
        $contentprop.Values = @("$($value.Value)")
        $contentprop.Timestamps = [double]::Parse((Get-Date -UFormat %s))

        $contentprops.Propertycontent = @($contentprop)

    write-host( "Writing value $($Value.value) to location $StatKey for vRealize Operations Manager object $VM" ) -ForegroundColor White -BackgroundColor Blue


As you can see in its simplest terms it is pulling values from one source and posting them to another.  To execute against an entire virtual center just comment out the cluster variables and write-host and remove ‘ -location $cluster’ from the $VMS variable.

NOTE:  The value is only updated when the script runs, if you need a value to update often then options are available with tools such as vRealize Orchestrator or even a cron job or scheduled task.

Output Examples

PowerShell (Yes, I’ve colour coded stuff to make it a bit easier to see)

vRealize Operations Manager


Now the data is in vROPs we can use its functions to create views, dashboards reports and alerts based on the values!



I’ll be exploring what can be done, in particular i’ve got thoughts about how it can be used to pull the application data that is being gathered by VMware Tools.

Hopefully this is useful for someone