I’m using the following Powershell script to get the Recovery setting of a protected VM, but I’m getting the error message in the output following the Powershell code below, can someone please tell me if there is something wrong with the script or the actual protected VM configuration on SRM 8.1.2 version?
Import-Module -Name D:\VMware\Scripts\SRM-Cmdlets-0.2\Meadowcroft.Srm.psd1
$credential = Get-Credential
Connect-VIServer -Server htapll0201.example.com
Connect-SrmServer -Credential $credential -RemoteCredential $credential
$pg = Get-SrmProtectionGroup "PBS pbsrmmuhp401 Prod PG"
$pginfo = $pg.GetInfo()
$pvms = Get-SrmProtectedVM -ProtectionGroup $pg
$rps = Get-SrmRecoveryPlan -ProtectionGroup $pg
$rpnames = $rps | %{ $_.GetInfo().Name }
$pvms | %{
$pvm = $_
Write-Host $pvm.Vm.Name
$rs = $rps | Select -First 1 | %{ $_.GetRecoverySettings($pvm.Vm.MoRef) }
}
$output = "" | select group, name, moRef, needsConfiguration, state, plans, priority, finalPowerState, preCallouts, postCallouts
$output.group = $pginfo.Name
$output.name = $pvm.Vm.Name
$output.moRef = $pvm.Vm.MoRef # this is necessary in case we can't retrieve the name when VC is unavailable
$output.needsConfiguration = $pvm.NeedsConfiguration
$output.state = $pvm.State
$output.plans = [string]::Join(",`r`n", $rpnames)
if ($rs) {
$output.priority = $rs.RecoveryPriority
$output.finalPowerState = $rs.FinalPowerState
$output.preCallouts = $rs.PrePowerOnCallouts.Count
$output.postCallouts = $rs.PostPowerOnCallouts.Count
}
$output
-----------------------------------------------------------------------
Name Port User
---- ---- ----
htapll0201.example.com 443 VSPHERE.LOCAL\Administrator
ServiceUri : https://10.10.10.10:9086/vcdr/extapi/sdk
SessionSecret : "50a6cce4c29a11f90e35fc487575e1424036b786"
User : administrator@vsphere.local
IsConnected : True
Port : 9086
Version : 8.1.2
Build : 12686166
ProductLine : srm
InstanceUuid : 9e240e3c-6c7e-4b8b-8170-7b33b39a4651
RefCount : 4
ExtensionData : VMware.VimAutomation.Srm.Views.SrmServiceInstance
Uid : /SrmServer=administrator@vsphere.local@10.10.10.10:9086/
Id : /SrmServer=administrator@vsphere.local@10.10.10.10:9086/
Name : 10.10.10.10
IsInUse : True
ftsrmlapp301
Exception calling "GetRecoverySettings" with "1" argument(s): "Object
reference not set to an instance of an object."
At line:19 char:35
+ ... = $rps | Select -First 1 | %{ $_.GetRecoverySettings($pvm.Vm.MoRef) }
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : NullReferenceException
group : PBS pbsrmmuhp401 Prod PG
name : ftsrmlapp301
moRef : VirtualMachine-vm-301
needsConfiguration : False
state : Ready
plans : PBS pbsrmmuhp401 Prod RP
priority :
finalPowerState :
preCallouts :
postCallouts :
I’m using the following Powershell script to get the Recovery setting of a protected VM, but I’m getting the error message in the output following the Powershell code below, can someone please tell me if there is something wrong with the script or the actual protected VM configuration on SRM 8.1.2 version?
Two users with the same question at approximately the same time?
In any case, shouldn't that be
$_.GetRecoverySettings($pvm.MoRef)
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD, there is no $PVM.Moref but there is $PVM.vm.moref you can try by your self if you want.
Run into same issue. After investigating, bug report has been submitted to engineering.
The workaround is to completely remove current PowerCLI and install PowerCLI 6.5.0R1
Procedures for uninstalling PowerCLI