[http://msdn.microsoft.com/en-us/library/hh850156(v=vs.85).aspx]. Replace the
name of the VM and the IP configuration as needed.
$vmName = "win81g2"
$Msvm_VirtualSystemManagementService = Get-WmiObject `
-Namespace root\virtualization\v2 `
-Class Msvm_VirtualSystemManagementService
$Msvm_ComputerSystem = Get-WmiObject -Namespace root\virtualization\v2 `
-Class Msvm_ComputerSystem -Filter "ElementName='$vmName'"
$Msvm_VirtualSystemSettingData =
($Msvm_ComputerSystem.GetRelated(«Msvm_VirtualSystemSettingData», `
"Msvm_SettingsDefineState", $null, $null, "SettingData", `
«ManagedElement», $false, $null) | % {$_})
$Msvm_SyntheticEthernetPortSettingData = $Msvm_VirtualSystemSettingData
.GetRelated(«Msvm_SyntheticEthernetPortSettingData»)
$Msvm_GuestNetworkAdapterConfiguration =
($Msvm_SyntheticEthernetPortSettingData
.GetRelated( `
"Msvm_GuestNetworkAdapterConfiguration", "Msvm_SettingDataComponent",
`
$null, $null, "PartComponent", "GroupComponent", $false, $null) | %
{$_})
$Msvm_GuestNetworkAdapterConfiguration.DHCPEnabled = $false
$Msvm_GuestNetworkAdapterConfiguration.IPAddresses = @("192.168.1.207")
$Msvm_GuestNetworkAdapterConfiguration.Subnets = @("255.255.255.0")
$Msvm_GuestNetworkAdapterConfiguration.DefaultGateways = @("192.168.1.1")
$Msvm_GuestNetworkAdapterConfiguration.DNSServers = @("192.168.1.10",
«192.168.1.11»)
$Msvm_VirtualSystemManagementService.SetGuestNetworkAdapterConfiguration(
`
$Msvm_ComputerSystem.Path,
$Msvm_GuestNetworkAdapterConfiguration.GetText(1))
Separating the virtual machine between the primary and the replica carries a
disadvantage. If additional virtual hard disks are added to the primary virtual machine,
those virtual hard disks will not automatically start replicating to the replica. The only
way to add the new virtual hard disks for the virtual machine to those being replicated
is to break the replication between the primary and the replica and then reestablish
replication by selecting the new virtual hard disks as part of the replication set. When
reestablishing replication, you can specify to use the existing virtual machine for the
initial data, which will optimize the amount of data required to seed the replica.
Additionally, enterprise virtualization management solutions like SCVMM will handle
this scenario automatically and add new disks as part of the replica configuration.
Windows Server 2016 improves on this situation by allowing new disks to be attached
to a VM without causing any errors and then allowing disks to be added or removed to