VMware Cloud Community
arindama
Contributor
Contributor

Re IP all Windows VM's through vCenter login

Hi Experts,

We have a requirement here to re IP all our VM's as we are moving to a new data center.

While trying to do so, I found a very good script from vmnomad.blogspot.com which I later customized to our need.

Script is running fine with the required parameters & updates, but its not able to change the IP address, though it says, it changed the IP address.

Command syntax from PowerCLI: NewreIP1.ps1 -Inventory .\Test-Inventory5.csv -VC vCenter

I think, this command syntax invoke-vmscript -ScriptText $changingIp -ScriptType bat -VM $vm.ServerName -GuestUser $vm.Username -GuestPassword $vm.Password  is not able to execute forcefully on the VM, the way it should.

Previous line output provides data perfectly, the ones which needs to be changed:

$changingIp = '%WINDIR%\system32\netsh.exe interface ipv4 set address name="' + $InterfaceName + '" source=static address=' + $vm.newIP + ' mask=' + $vm.newMask + ' gateway=' + $vm.newGateway + ' gwmetric=1 store=persistent'

Write-Host $changingIp

The script is added here as an attachment.

I tried to run the output of Write-Host $changingIp in couple of my VM's manually & they were able to change the IP address based on the data provided without any issues.

So, somehow Invoke-VMscript is not able to run on the VM with data acquired.

Any help will be great!

Thanks

Arindam

0 Kudos
1 Reply
daphnissov
Immortal
Immortal

Please don't double post here. You also posted in PowerCLI and that is the appropriate sub-forum for your question.

0 Kudos