Add Powershell parameters in the function like this:
Function Get-InstallDate { Param( [string][parameter(Mandatory=$true)] $VMHost ) $thisUUID = (Get-VMHost $VMHost | Get-EsxCli).system.uuid.get() $decDate = [Convert]::ToInt32($thisUUID.Split("-")[0], 16) $installDate = [timezone]::CurrentTimeZone.ToLocalTime(([datetime]'1/1/1970').AddSeconds($decDate)) [pscustomobject][ordered]@{ Name="$((Get-VMHost $VMHost).Name)" InstallDate=$installDate } }
Just running Get-InstallDate will prompt you for the hostname, or you can supply the parameter directly in the command with Get-InstallDate -VMHost myesxi.local.