Hi,
I am getting the below error when I execute the below script, please help
Script:
Connect-VIServer 10.10.10.6
$srm = Connect-SrmServer
$srmApi = $srm.ExtensionData
$protectionGroups = $srmApi.Protection.ListProtectionGroups()
$protectionGroups | % {
$protectionGroup = $_
$protectionGroupInfo = $protectionGroup.GetInfo()
# The following command lists the virtual machines associated with a protection group
$vms = $protectionGroup.ListAssociatedVms()
# The result of the above call is an array of references to the virtual machines at the vSphere API
# To populate the data from the vSphere connection, call the UpdateViewData method on each virtual machine view object
$vms | % {$_.UpdateViewData()}
# After the data is populated, use it to generate a report
$vms | %{
$output = "" | select VmName, PgName
$output.VmName = $_.Name
$output.PgName = $protectionGroupInfo.Name
$output
}
} | Format-Table @{Label="VM Name"; Expression={$_.VmName} }, @{Label="Protection group name"; Expression={$_.PgName} }
Error:
Exception calling "ListAssociatedVms" with "0" argument(s): "The operation is not supported on the object."
At D:\DS\SG1.ps1:65 char:5
+ $vms = $protectionGroup.ListAssociatedVms()
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : VimException
You cannot call a method on a null-valued expression.
At D:\DS\SG1.ps1:68 char:15
+ $vms | % {$_.UpdateViewData()}
+ ~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull