cancel
Showing results for 
Search instead for 
Did you mean: 
Create Post
Level 10

Configuring VMAN to show the Notes section of the VM attributes?

Jump to solution

Hi People,

I wanted to know if it is possible to configure the VMAN to show the VM description on the VMAN page to pull information from the VCenter Notes attributes?

THis will be good for more meaningful email alert notification and also when viweing the VMAN VM detailed view.

Thanks.

Labels (1)
1 Solution

 

This is not exactly what you are looking for, but hopefully it points you in the right direction:

# To avoid script with passwords, create a text file using seccure string to hold the encrypted passwords
# read-host -assecurestring | convertfrom-securestring | out-file C:\Path\to\file.txt`

Add-PSSnapin Vmware.VimAutomation.Core -ErrorAction SilentlyContinue
Add-PSSnapin SwisSnapin -ErrorAction SilentlyContinue

# Connect to Orion API using SWIS
$SwisServer = <yourserver>
$SWIScreds = Get-Credential

#$swis = Connect-Swis $SwisServer -Credential $SWISCred
$swis = Connect-Swis $SwisServer -Credential $SWISCred
# Get a list of the nodes to search for nodeID, you could look up each, I find it quicker to get them all first
$OrionNodes = Get-SwisData -SwisConnection $swis -Query "SELECT NodeID, DisplayName FROM Orion.Nodes"

function Get-VmBackupTimes ($VCenter, $username, $password) {
   $VCenterCred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $password
	Connect-VIServer $VCenter -Credential $VCenterCred
   $VMs = Get-VM # grab all the Vm's in the vCenter
   foreach ($VM in $VMs)
   {
      $VmNotes = $VM | Get-Annotation -Name "Last Backup"
      if (($VmNotes.Value).length -gt 0) { #grab all the machine with the property populated, for some reason excluding null values failed
			Write-Host 'Gathered backup for VM:' $VmNotes.AnnotatedEntity -ForegroundColor DarkGreen
			Set-NodeBackupProperty -NodeName $VmNotes.AnnotatedEntity -BackupTime $VMNotes.Value
      } else {
			Write-Host 'No backup time for VM:' $VmNotes.AnnotatedEntity -ForegroundColor Yellow
		}
	}
	# Disconnect-VIServer -Server $VCenter -Force
}

function Set-NodeBackupProperty ($NodeName, $BackupTime)
{
	$OrionServerData = $OrionNodes | where DisplayName -like $NodeName
	if ($OrionServerData.count -ne 0) {
	  $NodeId = $OrionServerData.NodeId
	  $Uri = "swis://localhost/Orion/Orion.Nodes/NodeID=$NodeId/CustomProperties";
		$CustomProps = @{ BackupTime = $BackupTime; }
		Set-SwisObject $swis -Uri $uri -Properties $customProps
		Write-Host 'Updating Orion Node: ' $NodeName -ForegroundColor Green
	}
}

Get-VmBackupTimes -VCenter <yourvcenter> -username <user> -password <password>

 

View solution in original post

4 Replies
Orion SDK/API and PowerCLI are your friends here.
Create a custom property, create a script that runs against your VCenterband grabs that info to fill the Custom property.
I have done that with a HyperV cluster at one of my clients. They wanted the comments of the Machines in Orion.
Level 12

Do you have any examples of you doing this?  I too wish VMAN natively could pull in all the things that rvtools does for free so that I could integrate all the work we have done on the VMWARE side of the house and not have to repeat that on the Orion side.  

 

This is not exactly what you are looking for, but hopefully it points you in the right direction:

# To avoid script with passwords, create a text file using seccure string to hold the encrypted passwords
# read-host -assecurestring | convertfrom-securestring | out-file C:\Path\to\file.txt`

Add-PSSnapin Vmware.VimAutomation.Core -ErrorAction SilentlyContinue
Add-PSSnapin SwisSnapin -ErrorAction SilentlyContinue

# Connect to Orion API using SWIS
$SwisServer = <yourserver>
$SWIScreds = Get-Credential

#$swis = Connect-Swis $SwisServer -Credential $SWISCred
$swis = Connect-Swis $SwisServer -Credential $SWISCred
# Get a list of the nodes to search for nodeID, you could look up each, I find it quicker to get them all first
$OrionNodes = Get-SwisData -SwisConnection $swis -Query "SELECT NodeID, DisplayName FROM Orion.Nodes"

function Get-VmBackupTimes ($VCenter, $username, $password) {
   $VCenterCred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $password
	Connect-VIServer $VCenter -Credential $VCenterCred
   $VMs = Get-VM # grab all the Vm's in the vCenter
   foreach ($VM in $VMs)
   {
      $VmNotes = $VM | Get-Annotation -Name "Last Backup"
      if (($VmNotes.Value).length -gt 0) { #grab all the machine with the property populated, for some reason excluding null values failed
			Write-Host 'Gathered backup for VM:' $VmNotes.AnnotatedEntity -ForegroundColor DarkGreen
			Set-NodeBackupProperty -NodeName $VmNotes.AnnotatedEntity -BackupTime $VMNotes.Value
      } else {
			Write-Host 'No backup time for VM:' $VmNotes.AnnotatedEntity -ForegroundColor Yellow
		}
	}
	# Disconnect-VIServer -Server $VCenter -Force
}

function Set-NodeBackupProperty ($NodeName, $BackupTime)
{
	$OrionServerData = $OrionNodes | where DisplayName -like $NodeName
	if ($OrionServerData.count -ne 0) {
	  $NodeId = $OrionServerData.NodeId
	  $Uri = "swis://localhost/Orion/Orion.Nodes/NodeID=$NodeId/CustomProperties";
		$CustomProps = @{ BackupTime = $BackupTime; }
		Set-SwisObject $swis -Uri $uri -Properties $customProps
		Write-Host 'Updating Orion Node: ' $NodeName -ForegroundColor Green
	}
}

Get-VmBackupTimes -VCenter <yourvcenter> -username <user> -password <password>

 

View solution in original post

Level 10
that's great, thanks for the pointer. I will update the thread with the new thread.
0 Kudos