Hello Friends
Just looking for automating the addition of IP Customization Settings on the Recovery Plans using powercli , found a API for the IP customization , anyone have any idea how we can set the values for these Objects
I am trying to Create the Recovery setting object , with IP Customizations , while setting the IpCustomizationSpec its throws an error
But if I create that as a standalone object it getting success ,
$testRS= New-Object VMware.VimAutomation.Srm.Views.SrmRecoverySettings
$testRS.VmIpCustomizationData = New-Object VMware.VimAutomation.Srm.Views.SrmVmIpCustomization
$testRS.VmIpCustomizationData.IpCustomizationMappings = New-Object VMware.VimAutomation.Srm.Views.SrmVmIpCustomizationIpCustomizationSpecMapping
$testRS.VmIpCustomizationData.IpCustomizationMappings.IpCustomizationSpec = New-Object VMware.VimAutomation.Srm.Views.SrmVmIpCustomizationIpCustomizationSpec
PS C:\Scripts> $testRS.VmIpCustomizationData.IpCustomizationMappings.IpCustomizationSpec = New-Object VMware.VimAutomation.Srm.Views.SrmVmIpCustomizationIpCustomizationSpec
InvalidOperation: The property 'IpCustomizationSpec' cannot be found on this object. Verify that the property exists and can be set.
PS C:\Scripts> New-Object VMware.VimAutomation.Srm.Views.SrmVmIpCustomizationIpCustomizationSpec
DnsSuffixes HostName NicCustomizationSpecs
----------- -------- ---------------------
PS C:\Scripts>
VmIpCustomization
NicCustomizationSpec
Hi,
Due to it being a complex object must do like this:
NOTE - have to use actual SiteUuid for your recovery site ... this one is just an example.
$testRS.IpCustomizationMappings = [pscustomobject]@{
IpCustomizationSpec = New-Object VMware.VimAutomation.Srm.Views.SrmVmIpCustomizationIpCustomizationSpec;
SiteUuid="323tyc10-f4c0-9m9z-v585-47474747try9";
}
Also note that some fields are arrays such as DnsSuffixes and DnsServerList:
$testRS.IpCustomizationMappings.IpCustomizationSpec.DnsSuffixes = @("mydomain1.com", "mydomain2.com")
ETC
$testRS.IpCustomizationMappings.IpCustomizationSpec.NicCustomizationSpecs.IpV4AddressSpecs.StaticAddressInfo.Address = "10.20.30.111"
You can create/populate the full object and then write it back to SRM config (thanks to Ben Meadowcraft's work):
i.e. partial snippets here after connecting to protected site and srmserver
$rp = Get-SrmRecoveryPlan -Name "my_srm_plan"
$vm = Get-Vm -Name "my_vmname"
$pvm = $rp | Get-SrmProtectedVM | Where-Object {($_.VmName -EQ $vm.Name )}
$recoverySettings = $pvm | Get-SrmRecoverySetting -RecoveryPlan $rp
$recoverySettings.VmIpCustomizationData.IpCustomizationMappings = $testRS.IpCustomizationMappings
Set-SrmRecoverySetting -RecoveryPlan $rp -Vm $vm -RecoverySettings $recoverySettings
Hope this helps.
cheers
Has anyone figured this out? I am having the hardest time with this
$SrmRecoverySettings = New-Object -TypeName vmware.vimautomation.srm.views.SRMVmIpCustomization
$SrmRecoverySettings.IpCustomizationMappings = [pscustomobject]@{
IpCustomizationSpec = New-Object VMware.VimAutomation.Srm.Views.SrmVmIpCustomizationIpCustomizationSpec;
SiteUuid="323tyc10-f4c0-9m9z-v585-47474747try9";
}
$SrmRecoverySettings.IpCustomizationMappings.IpCustomizationSpec.NicCustomizationSpecs.IpV4AddressSpecs.StaticAddressInfo.Address = "127.0.0.1"