VMware Cloud Community
tdubb123
Expert
Expert

powercli to reselect existing PG

I need to reselect the PG (not change) the PG on each vm.

how do it per vm with set-networkadapter -networkname ....

0 Kudos
4 Replies
tdubb123
Expert
Expert

Screen Shot 2020-02-19 at 7.26.26 PM.png

would something like this work?

0 Kudos
LucD
Leadership
Leadership

Yes, something like this should do the trick.

Get-VM -Server vcenter |

ForEach-Object -Process {

    Get-NetworkAdapter -VM $_ |

    Set-NetworkAdapter -NetworkName $_.NetworkName -Confirm:$false -RunAsync

}


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

0 Kudos
tdubb123
Expert
Expert

Hi Luc

I got this

Screen Shot 2020-02-20 at 5.53.42 AM.png

I started with

get-vm -name vm1, vm2 |

ForEach-Object -Process {

    Get-NetworkAdapter -VM $_ |

    Set-NetworkAdapter -NetworkName $_.NetworkName -Confirm:$false -RunAsync

}

0 Kudos
LucD
Leadership
Leadership

Try like this then

Get-VM -Server vcenter |

ForEach-Object -Process {

    Get-NetworkAdapter -VM $_ |

    ForEach-Object -Process {

        Set-NetworkAdapter -NetworkAdapter $_ -NetworkName $_.NetworkName -Confirm:$false

    }

}


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

0 Kudos