Hi All,
I tried to add some custom Guest Properties to a vApp which is already deployed according to this blog entry:
https://communities.vmware.com/thread/442664
My current script looks like this:
$AllvApp = Get-CIVApp -Name 'GuestPropTest'
$vm = $AllvApp | Get-CIVM
# Search for the guest properties section (OVF settings) - this is called "product section" in the API/CLI
$vmProductSection = $vm.ExtensionData.GetProductSections()
$vsa = $vmProductSection.ProductSection[0]
# Set the value of individual properties
($vsa.Items|Where-Object {$_.key -eq 'Owner'}).value = $AllvApp.Owner
# Commit the changes
$vmProductSection.UpdateServerData()
Remove-Variable AllvApp
Remove-Variable vmProductSection
Remove-Variable vsa
Remove-Variable vm
Unfortunately on my vCloud PowerCLI it always fails at the step where the example tries to instantiate the first list of guest properties.
Cannot index into a null array. At C:\Users\amarty\Desktop\Untitled1.ps1:7 char:1 + $vsa = $vmProductSection.ProductSection[0] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : NullArray
Now I'm not really a programmer and therefore I'm a bit lost on this...Is there anyone who could help me to get around this error so I can create the desired guest properties?
Thanks in advance & Regards
Linuxcrash