netcoreapp3.1/ParameterCompleter.ps1

#This function will register parameter completion for all cmdlet parameters which have ParameterCompleterAttribute
function EnableParameterCompleters($commandsAssemblyName){
    $assembly = [System.AppDomain]::CurrentDomain.GetAssemblies() | Where-Object {$_.GetName().Name -eq $commandsAssemblyName }
    $cmdletTypes = $assembly.GetTypes() | Where-Object {$_.GetCustomAttributes([System.Management.Automation.CmdletAttribute], $true)}

    foreach($type in $cmdletTypes){
         foreach($property in $type.GetProperties()){
            # Check for ParameterCompleterAttribute attribute
            $argumentCompleterAttribute =
                $property.GetCustomAttributes([VMware.VimAutomation.Sdk.Util10Ps.ParameterValidation.ParameterCompleterAttribute], $true)

            if($argumentCompleterAttribute){
                $cmdletAttribute = $type.GetCustomAttributes([System.Management.Automation.CmdletAttribute], $true)
                $cmdletName = "$($cmdletAttribute.VerbName)-$($cmdletAttribute.NounName)"
                $possibleValues =  $argumentCompleterAttribute[0].PossibleValues

                $tabCompletionScriptBlock = {
                    param($commandName, $parameterName, $wordToComplete)

                    return $possibleValues
                }.GetNewClosure()

                Register-ArgumentCompleter -CommandName $cmdletName -ParameterName $property.Name -ScriptBlock $tabCompletionScriptBlock
            }
        }
    }
}