I am trying to run this simple script
$srmApi = $srm.ExtensionData
$protectionGroups = $srmApi.Protection.ListProtectionGroups()
$protectionGroups | % {
$protectionGroup = $_
$protectionGroupInfo = $protectionGroup.GetInfo()
$protectedVms = $protectionGroup.ListAssociatedVms() ##Fails
$protectedVms | % { $_.Vm.UpdateViewData() }
$protectedVms | %{
$output = "" | select VmName, PgName
$output.VmName = $_.Vm.Name
$output.PgName = $protectionGroupInfo.Name
$output
}
}
However, I get the error -
Exception calling "ListAssociatedVms" with "0" argument(s): "The operation is not supported on the object."
+ $protectionGroups[0].ListAssociatedVms <<<< ()
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
The ListAssociatedVms method does exist as piping $protectionGroups[0] | gm shows it as a valid method.
Any ideas?
We are using vSphere Server 5.0.0 with PowerCli 5.5
Thanks in advance,
Jake
When you list the protected VMs you should see that each of them has a "Vm" property. This property has its own "Name" property which contains the name of the virtual machine.
The following would output the names of the protected VMs:
$ProtectionGroup.ListProtectedVMs() | %{ $_.Vm.Name }
Thanks Ben, I have tried your suggestion and it seems that having a custom SRM setup (shared recovery site) like I have doesn't work well with the SRM powercli cmdlets .For example I can't do a connect-srmserver without specifying a srm server, which is a prerequisite for listing VMs with the SRM api. Otherwise you get no results.
I echo this statement. In another thread I mentioned the same thing, that the cmdlets can't handle a shared recovery site since it assumes a connection to the primary SRM servers and won't let you specify the connection to a second one.