VMware Cloud Community
thiag2011
Enthusiast
Enthusiast
Jump to solution

Powercli to get ESXi version upgrade date

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!

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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

View solution in original post

Reply
0 Kudos
10 Replies
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos
thiag2011
Enthusiast
Enthusiast
Jump to solution

Hi Luc,

Both the installdate column and updatedate column returns blank.

Able to fetch only the esxi host name.

Can you pl help.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Which PowerCLI version are you using (do a Get-PowerCLIVersion)?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
thiag2011
Enthusiast
Enthusiast
Jump to solution

Hi LucD,

VMware vSphere PowerCLI 5.5 Release 1 build 1295336

This is the version.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos
thiag2011
Enthusiast
Enthusiast
Jump to solution

Great!!! It works as expected.

Thanks a lot.

Reply
0 Kudos
apsuthar
Contributor
Contributor
Jump to solution

Can you also help if we get the installed version and upgraded version ?

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

I suspect you mean from which version the ESXi node was upgraded?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
apsuthar
Contributor
Contributor
Jump to solution

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 ?

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos