Hi,
A little help please, as part of my script i am trying to change the backing on a list of vms which all have different portgroups, if they = this then change to that. Below is what i have i get no erros the script runs but the guest does not change and i have copied and pasted the variables from vCenter so should be no spelling issues.
foreach ($vm in $vmlist) {
$adp = get-vm $vm | get-networkadapter
if ($adp -eq $oldNet1){
set-networkadapter -NetworkName $PG1 -confirm:$false
}elseif ($adp -eq $oldNet2){
set-networkadapter -NetworkName $PG2 -confirm:$false
}elseif ($adp -eq $oldNet3){
set-networkadapter -NetworkName $PG3 -confirm:$false
}elseif ($adp -eq $oldNet4){
set-networkadapter -NetworkName $PG4 -confirm:$false
}
}
however if i run the one liner below it works fine.
get-vm $vm | get-NetworkAdapter | where {$_.NetworkName -eq $oldNet1} | set-networkadapter -NetworkName $PG1 -confirm:$false