$virtualportgroup = get-vmhost esxi1.wilmo.local | get-virtualswitch -Name vSwitch2 | get-virtualportgroup -name "VM Network 2" Get-VM DC | get-networkadapter | set-networkadapter -Networkname $virtualportgroup
QHalo wrote: » This worked for me. Obviously chop it up to match your environment. But this will move portgroups on the same vSwitch. What I've found with PowerCLI is that most of the time if you want to do something complicated that involves lots of pipes, create a variable. There's probably another way to do this but this does work. Good luck with PowerCLI. I love it.$virtualportgroup = get-vmhost esxi1.wilmo.local | get-virtualswitch -Name vSwitch2 | get-virtualportgroup -name "VM Network 2" Get-VM DC | get-networkadapter | set-networkadapter -Networkname $virtualportgroup
get-vm test_5 |Get-NetworkAdapter |where {$_.Name -eq "Network adapter 1"} |Set-NetworkAdapter -NetworkName $virtualportgroup
QHalo wrote: » Are you using the latest version of PowerCLI? I'm not sure why you needed the filter, but it's probably best anyway from a coding perspective. I thought about that last night as I posted that I should probably ensure that the network adapter I wanted to change was Network Adapter 1 but since I only had one, it worked either way.