VMware Cloud Community
OsburnM
Hot Shot
Hot Shot

How to rebuild vROps vApp Container Data from PowerCLI

Greetings all.  Wondering if I could get some help on this one.  We recently migrated our vROp 6.4 cluster to a new datacenter/vcenter using SRM & vSphere Replication and it didn't bring over the vApp data.  The recovered as straight VMs w/o any of the vApp properties.

There's an old KB on how to use PowerCLI for this scenario but was for a very old version of vROps back when it was still vCOps and had seperate UI & Analytics nodes but all that (including the vApp container data) has since changed.  https://kb.vmware.com/kb/2031891

I still have the source VMs objects still in my old vCenter and all the original vApp properties for each VM are still there so I'm guessing there's a way to powercli this.  Just looking for suggestions.

Thanks!

0 Kudos
4 Replies
LucD
Leadership
Leadership

Was there a specific reason why you didn't use the Export-VApp and Import-VApp cmdlets?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
OsburnM
Hot Shot
Hot Shot

Because it's a production vROps environment that has 7 Master/Replica/Data nodes in the analytics cluster along with two four-node Remote Collectors and over 14TB of Data moving from one physical datacenter to another over a WAN link and SRM/vSR was the only way to minimize significant downtime.  Otherwise, a simple export to an OVA would have been ideal.

0 Kudos
LucD
Leadership
Leadership

Not sure if this will help, but the following two snippets do an export - import of vApp properties.

It depends if the vApp will reconfigure if you change it's properties.

You might need to export/import the vApp settings as well.

The export

# Export vApp properties

$srcVApp = Get-VApp -Name TestVApp

$dstVApp = Get-VApp -Name TestVApp2

$srcVApp.ExtensionData.VAppConfig.Property | Export-Csv vappprops.csv -NoTypeInformation -UseCulture

The import

# Import vApp properties

$spec = New-Object VMware.Vim.VAppConfigSpec

Import-Csv .\vappprops.csv -UseCulture | %{

    $prop = New-Object VMware.Vim.VAppPropertySpec

    $prop.Info = New-Object VMware.Vim.VAppPropertyInfo

    $prop.Info.Category = $_.Category

    $prop.Info.ClassId = $_.ClassId

    $prop.Info.DefaultValue = $_.DefaultValue

    $prop.Info.Description = $_.Description

    $prop.Info.Id = $_.Id

    $prop.Info.InstanceId = $_.InstanceId

    $prop.Info.Key = $_.Key

    $prop.Info.Label = $_.Label

    $prop.Info.Type = $_.Type

    $prop.Info.TypeReference = $_.TypeReference

    $prop.Info.UserConfigurable = $_.UserConfigurable

    $prop.Info.Value = $_.Value

    $spec.Property += $prop

}

$dstVApp.ExtensionData.UpdateVAppConfig($spec)


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
OsburnM
Hot Shot
Hot Shot

So, we're close.  That helps to export properties (and product info)... but the Get-VApp cmdlet doesn't work in this case because even though vROps 6 uses vApp properties and vApp is "enabled", it's not a true vApp Container.  Here's what I've come up with so-far but it's still not quite right...

param($RCVM,$SRCVC,$DSTVC)

# NOTE:  Power off VM first

# Connect to Source vCenter

$Creds = Get-Credential

Connect-VIServer $SRCVC -Credential $Creds

# Export RC vApp Product & Properties

$srcRC = Get-VM $RCVM

$srcRCView = Get-View $srcRC

$srcRCVAppProduct = $srcRCView.Config.VAppConfig.Product | Export-Csv RCvAppProduct.csv -NoTypeInformation -UseCulture

$srcRCVAppProperty = $srcRCView.Config.VAppConfig.Property | Export-Csv RCvAppProperty.csv -NoTypeInformation -UseCulture

Disconnect-VIServer $SRCVC -Force -Confirm:$false

# Connect to Destination vCenter

Connect-VIServer $DSTVC -Credential $Creds

# Prep Destination vApp

$dstRC = Get-VM $RCVM

$dstRCView = Get-View $dstRC

# Import vApp Product

$spec = New-Object VMware.Vim.VAppConfigSpec

Import-Csv .\RCvAppProduct.csv -UseCulture | %{

    $prod = New-Object VMware.Vim.VAppProductSpec

    $prod.Info = New-Object VMware.Vim.VAppProductInfo

    $prod.Info.Key = $_.Key

    $prod.Info.ClassId = $_.ClassId

    $prod.Info.InstanceId = $_.InstanceId

    $prod.Info.Name = $_.Name

    $prod.Info.Vendor = $_.Vendor

    $prod.Info.Version = $_.Version 

    $prod.Info.FullVersion = $_.FullVersion

    $prod.Info.VendorUrl = $_.VendorUrl

    $prod.Info.ProductUrl = $_.ProductUrl

    $prod.Info.AppUrl = $_.AppUrl

    $spec.Property += $prod

}

$dstVApp.ExtensionData.UpdateVAppConfig($spec)

# Import vApp Properties

$spec = New-Object VMware.Vim.VAppConfigSpec

Import-Csv .\RCvAppProperty.csv -UseCulture | %{

    $prop = New-Object VMware.Vim.VAppPropertySpec

    $prop.Info = New-Object VMware.Vim.VAppPropertyInfo

    $prop.Info.Category = $_.Category

    $prop.Info.ClassId = $_.ClassId

    $prop.Info.DefaultValue = $_.DefaultValue

    $prop.Info.Description = $_.Description

    $prop.Info.Id = $_.Id

    $prop.Info.InstanceId = $_.InstanceId

    $prop.Info.Key = $_.Key

    $prop.Info.Label = $_.Label

    $prop.Info.Type = $_.Type

    $prop.Info.TypeReference = $_.TypeReference

    $prop.Info.UserConfigurable = $_.UserConfigurable

    $prop.Info.Value = $_.Value

    $spec.Property += $prop

}

$dstVApp.ExtensionData.UpdateVAppConfig($spec)

Disconnect-VIServer $DSTVC -Force -Confirm:$false

0 Kudos