We have been using these commands which have been working for a long time. We recently upgraded few Windows server's hardware version to 13. Due to that, following three commands no longer works for any VMs which are at hardware version 13(It works fine for all other VMs which are at hardware version 11, 9, 8, 7)
1.
Import-CSV $ImportName | ForEach-object {Set-NetworkAdapter -NetworkAdapter ( Get-NetworkAdapter $_.Name ) -NetworkName $VLAN -StartConnected $Connectivity -confirm:$false}
Here is the Error:
----------------------------------------------------
Get-NetworkAdapter : 3/4/2019 11:08:25 AM Get-NetworkAdapter Exception has been thrown by the target of an invocation.
+ Import-CSV $ImportName | ForEach-object {Set-NetworkAdapter -NetworkAdapter ( Ge ...
+ ~~
+ CategoryInfo : NotSpecified: (:) [Get-NetworkAdapter], VimException
+ FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.VirtualDevice.GetNe
tworkAdapter
2.
$Servers | ForEach-object { Get-VM (Get-VM -Name $_.Name) | Get-VMQuestion | Set-VMQuestion -Option $Option -Confirm:$false}
Here is the Error:
----------------------------------------------------
Set-VMQuestion : 3/4/2019 11:11:30 AM Set-VMQuestion Exception has been thrown by the target of an invocation.
+ $Servers | ForEach-object { Get-VM (Get-VM -Name $_.Name) | Get-VMQuestion | Se ...
+ ~~
+ CategoryInfo : NotSpecified: (:) [Set-VMQuestion], VimException
+ FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.SetVMQuestion
3.
Import-CSV $ImportName | ForEach-object { Remove-VM $_.Name -Confirm:$false }
Here is the Error:
----------------------------------------------------
Remove-VM : 3/4/2019 11:45:59 AM Remove-VM Exception has been thrown by the target of an invocation.
+ Import-CSV $ImportName | ForEach-object { Remove-VM $_.Name -Confirm:$false }
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Remove-VM], VimException
+ FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.RemoveVM
Any suggestions / thoughts will be appreciated. thank you in advance.
Thank you!!!!!
This "Exception has been thrown by the target of an invocation" is a bit of a catch all error.
I have seen this message occur for multiple reasons, but never because of the HW version I'm afraid.
I would start by suspecting the PowerCLI installation.
Which PowerCLI version are you using?
Do you have a fresh station where you can do a fresh PowerCLI installation, and do the test on that station?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you LucD for your answer.
We are running old version of power cli. it is PowerCLI 6.3 Release 1 build 37379081
If we upgrade to newer one, I am not sure how it would affect rest of our environment.
You could install the newer version on another box, and check if that solves the issue.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference