internal/dynamicparams/processHostname.ps1

$scriptBlock = {
    param (
        $commandName,
        
        $parameterName,
        
        $wordToComplete,
        
        $commandAst,
        
        $fakeBoundParameter
    )
    
    $start = Get-Date
    [Sqlcollaborative.Dbatools.TabExpansion.TabExpansionHost]::Scripts["processhostname"].LastExecution = $start
    
    $server = $fakeBoundParameter['SqlInstance']
    if (-not $server) {
        [Sqlcollaborative.Dbatools.TabExpansion.TabExpansionHost]::Scripts["processhostname"].LastDuration = (Get-Date) - $start
        return
    }
    $sqlCredential = $fakeBoundParameter['SqlCredential']
    
    try {
        if ($sqlCredential) { $instance = Connect-SqlInstance -SqlInstance $server -ErrorAction Stop }
        else { $instance = Connect-SqlInstance -SqlInstance $server -ErrorAction Stop }
        
        $instance.EnumProcesses().Host | Select-Object -Unique | Where-DbaObject -Like "$wordToComplete*" | ForEach-Object {
            if (-not ([string]::IsNullOrWhiteSpace($_))) { New-DbaTeppCompletionResult -CompletionText $_ -ToolTip $_ }
        }
    }
    catch {
        [Sqlcollaborative.Dbatools.TabExpansion.TabExpansionHost]::Scripts["processhostname"].LastDuration = (Get-Date) - $start
        return
    }
    finally {
        [Sqlcollaborative.Dbatools.TabExpansion.TabExpansionHost]::Scripts["processhostname"].LastDuration = (Get-Date) - $start
    }
}

Register-DbaTeppScriptblock -ScriptBlock $scriptBlock -Name processhostname