Automation

 View Only
  • 1.  Powercli to get ESXi version upgrade date

    Posted Dec 11, 2017 09:17 AM

    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!



  • 2.  RE: Powercli to get ESXi version upgrade date

    Posted Dec 11, 2017 09:39 AM

    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

        }}



  • 3.  RE: Powercli to get ESXi version upgrade date

    Posted Dec 11, 2017 10:47 AM

    Hi Luc,

    Both the installdate column and updatedate column returns blank.

    Able to fetch only the esxi host name.

    Can you pl help.



  • 4.  RE: Powercli to get ESXi version upgrade date

    Posted Dec 11, 2017 11:05 AM

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



  • 5.  RE: Powercli to get ESXi version upgrade date

    Posted Dec 11, 2017 12:13 PM

    Hi LucD,

    VMware vSphere PowerCLI 5.5 Release 1 build 1295336

    This is the version.



  • 6.  RE: Powercli to get ESXi version upgrade date
    Best Answer

    Posted Dec 11, 2017 12:16 PM

    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

        }}



  • 7.  RE: Powercli to get ESXi version upgrade date

    Posted Dec 11, 2017 12:40 PM

    Great!!! It works as expected.

    Thanks a lot.



  • 8.  RE: Powercli to get ESXi version upgrade date

    Posted Dec 07, 2022 07:02 AM

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



  • 9.  RE: Powercli to get ESXi version upgrade date

    Posted Dec 07, 2022 09:32 AM

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



  • 10.  RE: Powercli to get ESXi version upgrade date

    Posted Dec 08, 2022 03:13 AM

    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 ?



  • 11.  RE: Powercli to get ESXi version upgrade date

    Posted Dec 08, 2022 07:25 AM

    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.