Files
PowerCLI-Example-Scripts/Scripts/ESXInstallDate.ps1
dmilov fb641c8a1c License PowerCLI-Examples-Scripts repository under BSD-2 Clause (#462)
As part of the VMware open source program, we have to update this repository with the correct license and copyright information.
We add the BSD-2 Clause License for this repository.
We mark all source code provided by VMware with the Copyright notice under BSD-2 Clause license.

* Update repository license to BSD 2-Clause License

* Update Copyright
2021-06-07 09:58:47 +03:00

36 lines
1.0 KiB
PowerShell
Executable File

<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
<#
.SYNOPSIS Retrieve the installation date of an ESXi host
.NOTES Author: William Lam
.NOTES Site: www.virtuallyghetto.com
.NOTES Reference: http://www.virtuallyghetto.com/2016/10/super-easy-way-of-getting-esxi-installation-date-in-vsphere-6-5.html
.PARAMETER Vmhost
ESXi host to query installation date
.EXAMPLE
Get-Vmhost "mini" | Get-ESXInstallDate
#>
Function Get-ESXInstallDate {
param(
[Parameter(
Mandatory=$true,
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true)
]
[VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl]$Vmhost
)
if($Vmhost.Version -eq "6.5.0") {
$imageManager = Get-View ($Vmhost.ExtensionData.ConfigManager.ImageConfigManager)
$installDate = $imageManager.installDate()
Write-Host "$Vmhost was installed on $installDate"
} else {
Write-Host "ESXi must be running 6.5"
}
}