I used a short script to check a VIB version on each ESXi host in the past. However, I just tried using it again and get the error
Method invocation failed because [VMware.VimAutomation.ViCore.Impl.V1.EsxCli.EsxCliElementImpl] does not contain a method named 'list'.
At line:1 char:1
+ $esxcli.software.vib.list()
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (list:String) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound
I lot has changed not only now using 6.5 but I have a new desktop and reloaded PowerCLI since the last time I used it. Looks like maybe a module is missing? If I run $esxcli.software.vib is shows the 'list' element.
Here is the script -
Get-VMHost |
ForEach-Object -Process {
$esxcli = Get-EsxCli -V2 -VMHost $_
$esxcli.software.vib.list() | where "Name" -eq "nimble-ncs" |
select @{N='VMHost';E={$esxcli.VMHost.Name}},Name,Version,CreationDate,InstallDate,Vendor
} | Export-Csv -Path .\ncm.csv -UseCulture -NoTypeInformation
Anyone know what could be going on?
Thanks in advance
You are using the V2 switch.
The way to call a method has changed a bit with V2 (see PowerCLI 6.3 R1: Get-ESXCLI Why the V2?)
You should do
ForEach-Object -Process {
$esxcli = Get-EsxCli -V2 -VMHost $_
$esxcli.software.vib.list.Invoke() | where {$_.Name -eq "nimble-ncs"} |
select @{N = 'VMHost'; E = {$esxcli.VMHost.Name}}, Name, Version, CreationDate, InstallDate, Vendor
} | Export-Csv -Path .\ncm.csv -UseCulture -NoTypeInformation
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You are using the V2 switch.
The way to call a method has changed a bit with V2 (see PowerCLI 6.3 R1: Get-ESXCLI Why the V2?)
You should do
ForEach-Object -Process {
$esxcli = Get-EsxCli -V2 -VMHost $_
$esxcli.software.vib.list.Invoke() | where {$_.Name -eq "nimble-ncs"} |
select @{N = 'VMHost'; E = {$esxcli.VMHost.Name}}, Name, Version, CreationDate, InstallDate, Vendor
} | Export-Csv -Path .\ncm.csv -UseCulture -NoTypeInformation
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks, I just added the -v2 to see if that would help. Before I and now I get this
Object of type 'InternalVimApi_50.ManagedObjectReference' cannot be converted to type 'System.String'.
At line:5 char:4
+ $esxcli.software.vib.list.Invoke() | where "Name" -eq "nimble-ncs" ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], ArgumentException
+ FullyQualifiedErrorId : System.ArgumentException
Seems I lost the braces for the Where-clause during the copy/paste of the code.
I corrected the above, please try again.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hum..Still getting "Object of type 'InternalVimApi_50.ManagedObjectReference' cannot be converted to type 'System.String'."
Did you copy the updated script above?
I suspect you might not have this line correct
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes, did a direct copy paste of all of it.
I also tried to connect to one host at the command line
$esxcli = Get-EsxCli -V2 -VMHost myhost.com (real hostname not listed)
And then
PS C:\> $esxcli.software.vib.list.Invoke()
Object of type 'InternalVimApi_50.ManagedObjectReference' cannot be converted to type 'System.String'.
At line:1 char:1
+ $esxcli.software.vib.list.Invoke()
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], ArgumentException
+ FullyQualifiedErrorId : System.ArgumentException
Just to see what happened.
and
PS C:\> $esxcli.software.vib.list.Invoke() | where {$_.Name -eq "nimble-ncs"} |
select @{N = 'VMHost'; E = {$esxcli.VMHost.Name}}, Name, Version, CreationDate, InstallDate, Vendor
Object of type 'InternalVimApi_50.ManagedObjectReference' cannot be converted to type 'System.String'.
At line:1 char:1
+ $esxcli.software.vib.list.Invoke() | where {$_.Name -eq "nimble-ncs"} ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], ArgumentException
+ FullyQualifiedErrorId : System.ArgumentException
This works correctly for me.
With this code
ForEach-Object -Process {
$esxcli = Get-EsxCli -V2 -VMHost $_
$esxcli.software.vib.list.Invoke() | where {$_.Name -eq "nimble-ncs"} |
select @{N = 'VMHost'; E = {$esxcli.VMHost.Name}}, Name, Version, CreationDate, InstallDate, Vendor
} | Export-Csv -Path .\ncm.csv -UseCulture -NoTypeInformation
Which PowerCLI version are you using?
Do
Are you running this line by line at the prompt?
Or as a .ps1 script?
Or from the ISE or VSC?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I did a direct copy and paste of your code and I do still get the error -
Object of type 'InternalVimApi_50.ManagedObjectReference' cannot be converted to type 'System.String'.
At line:4 char:4
+ $esxcli.software.vib.list.Invoke() | where {$_.Name -eq "nimble-nc ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], ArgumentException
+ FullyQualifiedErrorId : System.ArgumentException
The version I am running
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 6.7.0.8... VMware.DeployAutomation {Add-DeployRule, Add-ProxyServer, Add-ScriptBundle, Copy-DeployRule...}
Script 6.7.0.8... VMware.ImageBuilder {Add-EsxSoftwareDepot, Add-EsxSoftwarePackage, Compare-EsxImageProfile, Export-Es...
Manifest 11.0.0.... VMware.PowerCLI
Script 6.7.0.1... VMware.Vim
Script 11.0.0.... VMware.VimAutomation.Cis.Core {Connect-CisServer, Disconnect-CisServer, Get-CisService}
Script 11.0.0.... VMware.VimAutomation.Cloud {Add-CIDatastore, Connect-CIServer, Disconnect-CIServer, Get-Catalog...}
Script 11.0.0.... VMware.VimAutomation.Common
Script 11.0.0.... VMware.VimAutomation.Core {Add-PassthroughDevice, Add-VirtualSwitchPhysicalNetworkAdapter, Add-VMHost, Add-...
Script 7.6.0.1... VMware.VimAutomation.HorizonView {Connect-HVServer, Disconnect-HVServer}
Script 10.0.0.... VMware.VimAutomation.License Get-LicenseDataManager
Script 11.0.0.... VMware.VimAutomation.Nsxt {Connect-NsxtServer, Disconnect-NsxtServer, Get-NsxtService}
Script 11.0.0.... VMware.VimAutomation.Sdk {Get-ErrorReport, Get-PSVersion, Get-InstallPath}
Script 11.0.0.... VMware.VimAutomation.Security {Get-SecurityInfo, Get-VTpm, Get-VTpmCertificate, Get-VTpmCSR...}
Script 10.0.0.... VMware.VimAutomation.Srm {Connect-SrmServer, Disconnect-SrmServer}
Script 11.0.0.... VMware.VimAutomation.Storage {Add-KeyManagementServer, Copy-VDisk, Export-SpbmStoragePolicy, Get-KeyManagement...
Script 1.3.0.0 VMware.VimAutomation.StorageUtility Update-VmfsDatastore
Script 11.0.0.... VMware.VimAutomation.Vds {Add-VDSwitchPhysicalNetworkAdapter, Add-VDSwitchVMHost, Export-VDPortGroup, Expo...
Script 11.0.0.... VMware.VimAutomation.Vmc {Connect-Vmc, Disconnect-Vmc, Get-VmcSddcNetworkService, Get-VmcService...}
Script 10.0.0.... VMware.VimAutomation.vROps {Connect-OMServer, Disconnect-OMServer, Get-OMAlert, Get-OMAlertDefinition...}
Script 6.5.1.7... VMware.VumAutomation {Add-EntityBaseline, Copy-Patch, Get-Baseline, Get-Compliance...}
Really appreciate your time and assistance!!
And which version are those ESXi nodes?
That Api_50 part in the error gets me worried.
PowerCLI 11.0.0 supports ESXi 6.0 and higher.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
We have a mix of 6.0 and 6.5 and these hosts I am trying to run the script on are all a fresh install of Cisco custom ISO at VMware ESXi, 6.5.0, 8294253
Did you already try stop/start of your PS/PowerCLI session?
Sometimes the internals get mixed up, and a fresh start of the session fixes it.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes, this morning I restarted my laptop and did a copy/paste of your code in PS to try one last time.
Just a silly test, can you try with another vib in the Where-clause?
ForEach-Object -Process {
$esxcli = Get-EsxCli -V2 -VMHost $_
$esxcli.software.vib.list.Invoke() | where {$_.Name -eq "tools-light"} |
select @{N = 'VMHost'; E = {$esxcli.VMHost.Name}}, Name, Version, CreationDate, InstallDate, Vendor
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
OK, I just got it working. I logged in with administrator@vsphere.local and that worked. Looks like it was a permissions error this whole time! I really appreciate your time on this!!
No problem, glad it is solved.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference