Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 233224

How to prompt for vmhost name?

$
0
0

I would like to re-purpose the script below (borrowed from Find ESXi installation date » VCDX56) and use it as a function and prompt me for a host name when I invoke it. Currently the script will run against all VMs in all connected vCenters. I would like for it to prompt me to run against a specific host. How can I accomplish this?

 

Function Get-InstallDate {

Get-VMHost | Sort Name | %{

  $thisUUID = (Get-EsxCli -VMHost $_.name).system.uuid.get()

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

  $installDate = [timezone]::CurrentTimeZone.ToLocalTime(([datetime]'1/1/1970').AddSeconds($decDate))

  [pscustomobject][ordered]@{

    Name="$($_.name)"

    InstallDate=$installDate

  } # end custom object

} # end host loop

}

 

 

Any help is appreciated.


Viewing all articles
Browse latest Browse all 233224

Trending Articles