Apparently it doesn't work right if you don't actually manually import the Vds plugin. This can be done using the following command:
Get-PSSnapin -Registered -Name VMware.VimAutomation.Vds
Question
I have a VM with 3 network adapters:
vNIC1 : OldPortGroup1 vNIC2 : OldPortGroup2 vNIC3 : OldPortGroup3
I need to change the port group of these adapters to NewPortGroup1, NewPortGroup2, NewPortGroup3. I do not know which vNIC is currently assign to what port group but I do know the old port group names. I need to assign the New port group to the vNIC based on its membership to the old port group. The following code does not work:
Get-Datacenter MyDatcenter | Get-VM MyVM | Get-NetworkAdapter | Where-Object { $_.NetworkName -like "OldPortGroup1" } | Set-NetworkAdapter -NetworkName NewPortGroup1
This will return all the vNICs for all virtual machines that are on that network. It does not obey the -VM parameter on Get-VM. As far as I am concerned it is impossible to do what I am thinking. I have tried if statements, switch statements, etc. Any ideas?
Solution
Apparently it doesn't work right if you don't actually manually import the Vds plugin. This can be done using the following command:
Get-PSSnapin -Registered -Name VMware.VimAutomation.Vds