Get-Credential Customization & Variable Scoping

Would it be possible to build out the Get-Credential UI a little more? It’s been invaluable but for some end-user facing purposes it would be nice to have the title display something other than “Windows PowerShell Credential Request.” Also could Enter be bound to OK?

Additionally, I’ve got a variable scoping issue. I am initially declaring a variable outside the page scope and initializing it as null so that the cached credential can be used across multiple pages. However if there are existing sessions or if I just leave my tab open, the dashboard app will refuse to start.


$pages = @()
$Session:userCredential = $null

$pages += New-UDPage -Name "Test-Page" -Content {
    if ($Session:userCredential -eq $null) {
        $Session:userCredential = Get-Credential -Message "Log in with your AD username and password"
        $me = get-aduser -Identity $session:userCredential.username -Properties displayname -Credential $Session:userCredential
        New-UDTypography "Hello, $($me.displayname), you successfully logged in"
    else {
        New-UDTypography "Hello, $($me.displayname), you're already logged in"
New-UDApp -Title 'Test' -Pages $pages
Product: PowerShell Universal
Version: 4.2.15