Hi,
Is there a command to find HBA/NIC FW and Drivers of multiple ESXi WITHOUT using SSH or plink to ESXi?
One detail : PowerCli version is 5.8 😞
Thanks,
For the NIC you could do something like this
Get-VMHost -PipelineVariable esx | %{
$esxcli = Get-EsxCli -VMHost $_ -V2
foreach($vmnic in $esxcli.network.nic.list.Invoke() | where{$_.Name -match "^vmnic"}){
$esxcli.network.nic.get.invoke(@{nicname=$vmnic.Name}) |
Select @{N='VMHost';E={$esx.Name}},
@{N='vmnic';E={$vmnic.Name}},
@{N='Description';E={$vmnic.Description}},
@{N='MAC';E={$vmnic.MACAddress}},
@{N='Driver';E={$_.DriverInfo.Driver}},
@{N='Version';E={$_.DriverInfo.Version}},
@{N='Firmware';E={$_.DriverInfo.FirmwareVersion}}
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
For the HBA, when they are FC, you could do
Get-VMHost -PipelineVariable esx | %{
$esxcli = Get-EsxCli -VMHost $_ -V2
$esxcli.storage.san.fc.list.Invoke() |
Select @{N='VMHost';E={$esx.Name}},
Adapter,DriverName,DriverVersion,FirmwareVersion,HardwareVersion
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD,
Thanks,
I've already found these scripts... but if I'm right (need to check) argument "v2" did not exist un get-esxcli from powercli 5.8 🙂
So, I suppose there no other solutions without updating powercli or use plink/ssh command?
The V2 switch primarily adds an easier way to create and pass parameters to the esxcli commands.
Pre-V2 you had to pass the exact number of parameters to each call, and replace the ones that didn't need/use by $null.
But in theory most of the calls can be made through the pre-V2 Get-EsxCli cmdlet as well.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
It's a good news 🙂
But concretely, how do we "to pass the exact number of parameters to each call, and replace the ones that didn't need/use by $null" ?! I'm not sure to understand your answer 😞
Let's take a simple example, to add a device.
In the old system ($esxcli) you have to specify 2 parameters.
In the V2 system ($esxcliv2) there are 2 parameters, but one is optional, and you don't have to give that one.
In practice the same call in the two version would be done like this
$esxcli.device.add('vmhba2',$null)
$sArg = @{
deviceidentifier = 'vmhba2'
}
$esxcliv2.device.add.Invoke($sArg)
To "see" the parameters in the old system, you call the method without any parameters and parenthesis.
In the new system, you can extract the hash table with parameters with the CreateArgs method. Then it is just a matter of creating that hash table, and you can leave out the optional entries you don't need.
I hope that makes it a bit clearer.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I thought it was clear... until the partial output 🙂
foreach ($VMHost in $VMHosts) {
$VMHostName = $VMhost.Name
$esxcli = $VMHost | Get-EsxCli
$list += $esxcli.storage.san.fc.list.invoke() | Select @{N='VMHost';E={$VMHostName}},Adapter,DriverName,DriverVersion,FirmwareVersion,HardwareVersion # VMHostHBA command #$List += get-VMHostHBA -VMHost $VMHost -Device }
Output is only hostname and "vmhba1" & "vmhba2"...
Not sure if something went wrong when you copied my code, but that is not the script I gave earlier.
And the Get-EsxCli doesn't have the -V2 switch, while you it uses the Invoke() method, which is a V2 feature.
Can you try with the script I provided?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I'm sorry, I understood I had to adapt your script due to my current version of PowerCLI.
I used your script as is (or almost) :
foreach ($VMHost in $VMHosts)
{
Get-VMHost -PipelineVariable esx | %{
$esxcli = Get-EsxCli -VMHost $_ -V2
$esxcli.storage.san.fc.list.Invoke() |
Select @{N='VMHost';E={$VMHost.Name}},
Adapter,DriverName,DriverBersion,FirmwareVersion,HardwareVersion
}
}
and it returns :
Get-VMHost : A parameter cannot be found that matches parameter name 'pipelineVariable'.
At [...]
+ CategoryInfo : InvalidArgument: (:) [Get-VMHost], ParameterBindingException
+ FullyQualifiedErrorId : NamedParamterNotFound,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetVMHost
I've also replaced "esx" by "$VMHost,", Line 1 : Same result ...
That is correct, but you also have to drop the Invoke() method.
Like this
Get-VMHost -PipelineVariable esx | %{
$esxcli = Get-EsxCli -VMHost $esx
$esxcli.storage.san.fc.list.() |
Select @{N='VMHost';E={$esx.Name}},
Adapter,DriverName,DriverVersion,FirmwareVersion,HardwareVersion
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I've tested with removing "." before "()"
Get-VMHost -PipelineVariable esx | %{
$esxcli = Get-EsxCli -VMHost $esx
$esxcli.storage.san.fc.list() |
Select @{N='VMHost';E={$esx.Name}},
Adapter,DriverName,DriverVersion,FirmwareVersion,HardwareVersion
}
But, output is still regarding "PipelineVariable" error
Does this parameter works with PowerCLI 5.8?
Looks like you're on an older PowerShell version as well (check by displaying $psversiontable).
Try like this (and yes, that dot shouldn't have been there).
foreach($esx in Get-VMHost){
$esxcli = Get-EsxCli -VMHost $esx
$esxcli.storage.san.fc.list() |
Select @{N='VMHost';E={$esx.Name}},
Adapter,DriverName,DriverVersion,FirmwareVersion,HardwareVersion
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hu, 3.0 !
Another part to upgrade asap
Your script remove the error, but not the output : there are only Host & Adapter names...
Then I'm afraid that must be something due to the older PowerCLI version.
Don't you have a box somewhere where you can use a newer PowerCLI version?
Why are you obliged to stay with 5.8?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
In fact, it's essentially because we've got a lot of scripts and we already experencied issues during a powercli upgrade on another vCenter...
But if it's a the last solution in your POV, we'll find a solution : use esxcli or upgrade PowerShell/powercli !
Many thanks LucD for your time!
LucD, I've just found this KB : https://kb.vmware.com/kb/1002413
It seems retrieve FW is not possible in vSphere < 6.0...
So I'll use SSH in a first time