I have used the below script which works fine for assigning IPv4 address to all Linux VMs :
However the same script fails for IPv6
Connect-VIServer x.x.x.x
# Pop-up that will prompt for the ESX credentials
$HostCred = $Host.UI.PromptForCredential("Please enter credentials", "Enter ESXi host credentials", "", "")
# Pop-up that will prompt for the VM credentials
$GuestCred = $Host.UI.PromptForCredential("Please enter credentials", "Enter Guest credentials", "", "")
# Populating variable from the .csv file
$vmlist = Import-CSV C:vms6.csv
foreach ($item in $vmlist) {
# I like to map out my variables
$vmname = $item.vmname
$ip6addr = $item.ipaddress6
#$subnet = $item.subnet
#$policy = $item.policy
#$gateway = $item.gateway
#$pdnswins = $item.pdnswins
#$sdnswins = $item.sdnswins
#Get the current interface info
$GuestInterface = Get-VMGuestNetworkInterface -VM $vmname -HostCredential $HostCred -GuestCredential $GuestCred |Where-Object {$_.Description -like "Ethernet"}
#echo $GuestInterface
#If the IP in the VM matches, then I don't need to update
If ($ip6addr -ne $($GuestInterface.ip)) {
Set-VMGuestNetworkInterface -VMGuestNetworkInterface $GuestInterface -HostCredential $HostCred -GuestCredential $GuestCred -IP $ip6addr
}
}