VMware Cloud Community
tkcoder
Contributor
Contributor

switch to public nic

Hi, I am new to PowerCli. I need to write a script to switch VM's network from internal to public . Can anyone help me how to do this using PowerCLI cmdlet ?

Thanks.

0 Kudos
2 Replies
LucD
Leadership
Leadership

This should do the trick

$tgtPg = <internal-portgroup-name>
$newPg = <public-portgroup-name>

Get-VM | %{
	$net = $_ | Get-NetworkAdapter | where {$_.NetworkName -eq $tgtPg}
	$net | Set-NetworkAdapter -NetworkName $newPg -Confirm:$false
}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
tkcoder
Contributor
Contributor

thanks..by the way, how do you change VM's IP address ?

0 Kudos