Tab completion for datasource names in New-PWLogin

I figured out how to get tab completion for datasources on the New-PWLogin, even puts in the quote marks for you.

Add this to your profile.ps1 file:

# Silently import PWPS_DAB
Import-Module PWPS_DAB        -Verbose:$false -ErrorAction Stop -DisableNameChecking 6> $Null

# Setup tab completion for New-PWLogin
$dsTabBlock = {
    param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters)
    $dsList = Get-PWDSConfigEntry | Where-Object {$_.FullName -like "$wordToComplete*"} | Sort
    $dsList | ForEach-Object {
        New-Object -Type System.Management.Automation.CompletionResult -ArgumentList "'$($_.FullName)'",
            "$($_.Name) ($($_.Fullname))"
Register-ArgumentCompleter -CommandName New-PWLogin -ParameterName DatasourceName -ScriptBlock $dsTabBlock

In addition to regular tab completion of datasource names you can also get a list of the datasources by:

If you use the ISE after typing "New-PWLogin -DatasourceName " it will bring up a list displaying the display name of the datasource, but it will fill in the server:datasource form of the datasource.

If you use the regular command window or the Windows Terminal app after typing New-PWLogin press ctrl+space and it will bring up a menu of datasources, and again the menu lists the display name of the datasource but enters the server:datasource form.