I had to change 200 server IP addresses as part of a migration, it sucks, but this is how I did it.
$wmi = Get-WmiObject win32_networkadapterconfiguration -filter "ipenabled = 'true'" -ComputerName sql2012
$CurrentNICIndex = $wmi.CurrentNICIndex # this might not work, i just added for the example
$wmi.EnableStatic($ip, $subnet) | Out-Null
[int]$Loops = 0
do {
Start-Sleep -Seconds 10
$Loops++
}
until ((Test-Connection -Cn $ip -BufferSize 16 -Count 1 -ea 0 -quiet) -or $Loops -ge 30) #Use the New IP to connect, gives it a bit to update
if ($Loops -lt 30) {
$NetworkAdapter = Get-WmiObject -Class Win32_NetworkAdapterConfiguration -computername "$IP" -filter "Index = $CurrentNICIndex" #Use the New IP to connect, remove the CurrentNicIndex if its causeing problems
$NetworkAdapter.SetGateways($Gateway) | Out-Null
$NetworkAdapter.SetDNSServerSearchOrder($DNSArr) | Out-Null
$NetworkAdapter.SetDynamicDNSRegistration("TRUE") | Out-Null
also if your changing subnets this wont work, unless the new network is contactable of course.