I would like to fetch the ESXi host upgrade date (eg: date when the ESXi host has been upgraded from build 3248547 to 6480324).
Could you please share the powercli script for the same.
Thank you!
Ok, then you don't have the V2 option for Get-EsxCli.
Try like this
Get-VMHost |
Select Name,
@{N='InstallationDate';E={
$script:esxcli = Get-EsxCli -VMHost $_
$epoch = $script:esxcli.system.uuid.get().Split('-')[0]
[timezone]::CurrentTimeZone.ToLocalTime(([datetime]'1/1/1970').AddSeconds([int]"0x$($epoch)"))}},
@{N='UpgradeDate';E={
$script:esxcli.software.vib.list() | where{$_.Name -eq 'esx-base'} | select -ExpandProperty InstallDate
}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try like this.
Note that the UpgradeDate will only be correct when the upgrade you envision was the last upgrade.
If that is not the case, then an alternative is to look at the Task and Event, or eventually the esxupdate.log
Get-VMHost |
Select Name,
@{N='InstallationDate';E={
$script:esxcli = Get-EsxCli -VMHost $_ -V2
$epoch = $script:esxcli.system.uuid.get.Invoke().Split('-')[0]
[timezone]::CurrentTimeZone.ToLocalTime(([datetime]'1/1/1970').AddSeconds([int]"0x$($epoch)"))}},
@{N='UpgradeDate';E={
$script:esxcli.software.vib.list.Invoke() | where{$_.Name -eq 'esx-base'} | select -ExpandProperty InstallDate
}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Luc,
Both the installdate column and updatedate column returns blank.
Able to fetch only the esxi host name.
Can you pl help.
Which PowerCLI version are you using (do a Get-PowerCLIVersion)?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD,
VMware vSphere PowerCLI 5.5 Release 1 build 1295336
This is the version.
Ok, then you don't have the V2 option for Get-EsxCli.
Try like this
Get-VMHost |
Select Name,
@{N='InstallationDate';E={
$script:esxcli = Get-EsxCli -VMHost $_
$epoch = $script:esxcli.system.uuid.get().Split('-')[0]
[timezone]::CurrentTimeZone.ToLocalTime(([datetime]'1/1/1970').AddSeconds([int]"0x$($epoch)"))}},
@{N='UpgradeDate';E={
$script:esxcli.software.vib.list() | where{$_.Name -eq 'esx-base'} | select -ExpandProperty InstallDate
}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Great!!! It works as expected.
Thanks a lot.
Can you also help if we get the installed version and upgraded version ?
I suspect you mean from which version the ESXi node was upgraded?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks for the response 🙂
I mean the Yes, basically i was looking for a history of upgrade not sure possible ? For example - Initial OS installed date with version, followed by the upgrades. Possible ?
Not sure, you might want to check the InfoUpgradeEvent with Get-VIEvent if that contains some information.
But if it does, the history will in any case be limited by the time interval during which you keep Tasks and Events in your VCSA.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference