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.
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
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