I'm using Set-Network Adapter to fix-up guest servers when a portgroup is renamed. The request seems to make the required changes then crashses. In vCenter I don't see any errors in the Recent Tasks list.
I am using the following code:
Get-VMHost vmware.host | Get-VM | Get-NetworkAdapter | Where {$_.NetworkName -eq "old_name"} | Set-NetworkAdapter -NetworkName "new_name"-Confirm:$false
The error is:
Set-NetworkAdapter : 17/10/2012 12:16:56 p.m. Set-NetworkAdapter Operation is not valid due to the current
state of the object.
At line:1 char:114
+ ... old_name"} | Set-NetworkAdapter -NetworkName "new_name" -Confirm:$false
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Set-NetworkAdapter], VimException
+ FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.VirtualDevice.
SetNetworkAdapter
This is using PowerCLI 5.1 Release 1 against vCenter 5.0 and ESXi 5.0.
Any ideas how to either find out more about why it's failing or fix it.
Thanks
Iain