VMware Cloud Community
holashh
Enthusiast
Enthusiast
Jump to solution

Unable to setRecoverySettings over the SRM API with powerCLI

Hello all,

I am create script for automation of adding server into SRM with requested settings, like priority, postRecoverySteps and so on.

I am strugled in the last step to set the requested settings to the SRM plan over a method srmPlan.SetRecoverySettings(vm, settings) with the following error:

Exception calling "SetRecoverySettings" with "2" argument(s): "fault.drextapi.fault.InvalidArgument.summary"

At C:\PowerShell\srm\SRM-Cmdlets\SrmFunctions.ps1:726 char:3                                               

+         $RecoveryPlan.SetRecoverySettings($moRef, $RecoverySettings)                                     

+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                     

    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException                              

    + FullyQualifiedErrorId : VimException                                                                 

Could anybody or BenMeadowcroft helps me with this,

thank you all in advance.

Tags (1)
1 Solution

Accepted Solutions
holashh
Enthusiast
Enthusiast
Jump to solution

I fixed this for me few weeks ago and the fix was really pitty, as I forgot to read RecoveryPriority string definitions,

So the whole issue was that I used "high" instead of "higher", so this was the issue

View solution in original post

3 Replies
admin
Immortal
Immortal
Jump to solution

I would suggest asking this question in the PowerCLI (or SRM) community forums, you may get a faster response. To help answer it in the public forum it would be good to check the values that you are passing into the function to ensure they are correct. If you are able to share the current values of $moRef and $RecoverySettings in those forums in may help narrow the issue down.

holashh
Enthusiast
Enthusiast
Jump to solution

Hello Ben,

I've already asked my question in both communities, without any reasonable answer, so I want to ask you, because I would like to use your helper module, where I get the same result, I've used your functions as are written here: Using PowerCLI to Change SRM Recovery Settings – BenMeadowcroft.com but we are using SRM 6.1.1 and powerCLI 6.0.1/6.5.1

My script looks like this:

$vm = "MyVM"

$cred = Get-Credential

$vic = "vcenter"

connect-viserver $vic -credential $cred

$vmToAdd = Get-VM $vm

$vmToAdd | select name

$vmMoref = $vmToAdd | get-view

$vmMoref = $vmMoref.moref

$srmConnection = Connect-SrmServer $vic -credential $cred

#List all protection groups associated with the SRM server.

$srmApi = $srmConnection.ExtensionData

$protectionGroups = $srmApi.Protection.ListProtectionGroups()

$targetProtectionGroup = $protectionGroups | where { $_.GetInfo().Name -eq "deudpfran1esx SVM" }

#set VM SRM settings

$pvms = $targetProtectionGroup.listProtectedVms()

$rps = $targetProtectionGroup.ListRecoveryPlans()

$rp = $rps[0]

$pvm = $pvms | where {$_.vm.moref -eq $vmmoref}

$pvms[$i].Vm.MoRef

$rs = $rp.GetRecoverySettings($pvm.Vm.MoRef)

$rs

$rs.RecoveryPriority = "high"

   

write "settings after"

$rs

$rp.SetRecoverySettings($pvm.vm.moref, $rs)

   

write "disconnecting srm and viserver"

disconnect-srmserver $vic -confirm:$false

disconnect-viserver $vic -confirm:$false

results you suggest to share are as follows:

$moRef

$pvms | where {$_.vm.moref -eq $vmmoref} | select {$_.vm.moref}

$_.vm.moref

VirtualMachine-vm-77652

$vmMoref

Type                                                        Value

VirtualMachine                                              vm-77652

$recoverSettings

before change:

ChangeVersion         : 2
Status                : ok
RecoveryPriority      : normal
SkipGuestShutDown     : False
PowerOnTimeoutSeconds : 300
PowerOnDelaySeconds   : 0
PowerOffTimeoutSeconds: 300
FinalPowerState       : poweredOff

LocalFaultToleranceState  : False

RemoteFaultToleranceState : False

PrePowerOnCallouts    :
PostPowerOnCallouts   :

after change (I changed here just the RecoveryPriority):

ChangeVersion         : 2
Status                : ok
RecoveryPriority      : high
SkipGuestShutDown     : False
PowerOnTimeoutSeconds : 300
PowerOnDelaySeconds   : 0
PowerOffTimeoutSeconds: 300
FinalPowerState       : poweredOff

LocalFaultToleranceState  : False

RemoteFaultToleranceState : False

PrePowerOnCallouts    :
PostPowerOnCallouts   :

And here is the result:

$rp.SetRecoverySettings($pvm.vm.moref, $rs)

Exception calling "SetRecoverySettings" with "2" argument(s): "fault.drextapi.fault.InvalidArgument.summary"

At line:1 char:1

+ $rp.SetRecoverySettings($pvm.vm.moref, $rs)

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

    + FullyQualifiedErrorId : VimException

Could you please check this for me, after all I will share it with the community.

Thanks,

Holashh

0 Kudos
holashh
Enthusiast
Enthusiast
Jump to solution

I fixed this for me few weeks ago and the fix was really pitty, as I forgot to read RecoveryPriority string definitions,

So the whole issue was that I used "high" instead of "higher", so this was the issue