When booting a virtual standby export, the standby machine will be presented with new virtual hardware and in the case of the network card a new MAC address. This causes windows to initialize the hardware and default to a DHCP assigned IP address. Some customers may need to be able to revert to the static IP addresses their standby servers were initially configured with in an automated fashion at the time the machine boots.
Warning: All scripts provided in this article are meant to be used as examples and are not supported by AppAssure. For more information on AppAssure scripting support, click here.
Here is the sample IPchange.ps1 script:
<#Input Info;#>
$adaptername = “Main Network Card”;
$ipaddress = “10.23.20.150″;
$mask = “255.255.0.0″;
$dnsaddress = “10.23.20.151″;
$gateway = “10.23.0.1″;
<#Get Active NIC;#>
$nic = Get-WmiObject win32_networkadapterconfiguration -Filter ‘ipenabled = “true”‘;
if ($nic.ipaddress -ne $ipaddress)
{
<#Change IP settings;#>
$nic.EnableStatic($ipaddress,$mask);
$nic.SetGateways($gateway,1);
$nic.SetDNSServerSearchOrder($dnsaddress);
<#Change Adapter Name;#>
$adapter = Get-WMiObject win32_networkadapter -Filter “index= $($nic.index)”;
$adapter.NetConnectionID = $adaptername;
$adapter.Put();
ipconfig /registerdns > $null;
}