HI gurus
I need to change around 100 VM from one portgroup to another portgroup, is this possible using PowerCLI
Thanks in advance
With Get-NetworkAdapter and Set-NetworkAdapter
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
L.
Thanks I got this far, do you think i am in the right direction
$vm='myvmtomove'
$destination='myesxihost'
$Datastore='myDatastore'
$destinationPortG='PortgroupLabel'
$networkadapter=get-networkadapterr -VM $vm
move-vm $vm -destination $destination -networkadapter $networkadapter -portgroup $destinationPortG -datastore $datastore
this will move the vm to another esxi host on a different cluster and change the VLAN ID for destination and datastore also as well
let me know if I am close
I thought you just wanted to change the Portgroup for each VM.
Not sure why the Move-VM is there?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
L.
My bad on making this clear
I have vms that I want to move them from one cluster to another new cluster within the same data center , also I would like to move them to a new datastore and to a new portgroup within the new cluster , I thought I could use the move-vm to accomplish this as I used this move-vm to move between cluster and different datastore, I hope I make sense now.
Thanks
Ok, can you try something like this?
$toCluster = 'newCluster'
$newDatastore = 'newDatastore'
$newPortgroup = 'newPortgroup'
Get-Cluster -Name $fromCluster | Get-VM |
ForEach-Object -Process {
Move-VM -VM $_ -Datastore $newDatastore -PortGroup $newPortgroup -Destination $toCluster -Confirm:$false
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference