Hi,
I am using below commands, changing IP works, but DNS command fails, error ‘unable to connect to remote computer’. I think as IP has changed invoke-vmscript is not able to connect to machine, is there any better way, please advise;
$changingIp = ‘%WINDIR%\system32\netsh.exe interface ipv4 set address name="’ + $adapterName + ‘" source=static address=’ + $newIP + ’ mask=’ + $newMask + ’ gateway=’ + $newGateWay + ’ gwmetric=1 store=persistent’
$cmdDNS = ‘%WINDIR%\system32\netsh.exe interface ipv4 set dnsservers name="’ + $adapterName + ‘" source=static address=’ + $newDNS + ’ index=1’
Invoke-VMScript -VM $vm -ScriptType Bat -ScriptText $changingIp -GuestCredential $serverCredential
Invoke-VMScript -VM $vm -ScriptType Bat -ScriptText $cmdDNS -Verbose -GuestCredential $serverCredential
Rgds,
Kishor