VMware Cloud Community
Mallik7
Enthusiast
Enthusiast
Jump to solution

Need a powerCLI script that helps to capture the ESXi hosts install date for the given servers (should be able to capture from the input text file) for ESXi 5.5, 6.0 and 6.5 versions

Need a powerCLI script that helps to capture the ESXi host install date for the given hosts (should be able to capture from the input text file) for ESXi 5.5, 6.0 and 6.5 versions and the output to be saved in a .csv output file. Can some one help asap please. Thanks in advance.

1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try like this

$names = Get-Content -Path .\esx-names.txt

Get-VMHost -Name $names |

Select Name,

    @{N='InstallDate';E={

        $esxcli = Get-EsxCli -VMHost $_ -V2

        $uuid = $esxcli.system.uuid.get.Invoke()

        $installDate = [Convert]::ToInt32($uuid.Split("-")[0], 16)

        [System.TimeZone]::CurrentTimeZone.ToLocalTime(([datetime]'1/1/1970').AddSeconds($installDate))

    }} |

Export-Csv -Path .\report.csv -NoTypeInformation -UseCulture


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

View solution in original post

1 Reply
LucD
Leadership
Leadership
Jump to solution

Try like this

$names = Get-Content -Path .\esx-names.txt

Get-VMHost -Name $names |

Select Name,

    @{N='InstallDate';E={

        $esxcli = Get-EsxCli -VMHost $_ -V2

        $uuid = $esxcli.system.uuid.get.Invoke()

        $installDate = [Convert]::ToInt32($uuid.Split("-")[0], 16)

        [System.TimeZone]::CurrentTimeZone.ToLocalTime(([datetime]'1/1/1970').AddSeconds($installDate))

    }} |

Export-Csv -Path .\report.csv -NoTypeInformation -UseCulture


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