Show Script Output on page


#1

How can I get the result of my script on to the page? I’ve started off easy and just trying to get the LAPS password and show it to the user.
My script blocks are running as I can see the password within the toast but I can’t see to find any way to display it back on the page. I’ve tried adding new paragraphs, cards, pages etc but they all just show blank and don’t update when hitting submit.

$Page2 = New-UDPage -Name “LAPS” -Icon key -Content {

New-UDInput -Title "Select me" -Endpoint {
    param([ValidateSet("Domain1.Local", "Domain2.local")]$SelectedDomain,
        [string]$ComputerName)

    If ($SelectedDomain -like "Domain1.Local") {
        $LAPSpassword = Get-ADComputer -Filter {name -like $ComputerName} -SearchBase 'DC=Domain1,DC=local' -Server 'Domain1.local' -Properties ms-Mcs-AdmPwd | Select-Object ms-Mcs-AdmPwd
    }
    if ($SelectedDomain -like "Domain2.local") {
        $LAPSpassword = Get-ADComputer -Filter {name -like $ComputerName} -SearchBase 'DC=Domain2,DC=local' -Server 'Domain2.local' -Properties ms-Mcs-AdmPwd | Select-Object ms-Mcs-AdmPwd
    }

    # This toast works and shows password
    New-UDInputAction -Toast "Laps Password is: $LAPSpassword"
    
    # These don't work.    
    New-UDParagraph -Text "$LAPSpassword"
    New-UDParagraph -Text "$SelectedDomain"
  
} -FontColor "black"

}


#2

Here is what i do for my password resets:

https://pastebin.com/uzKzBSue

The Variables $PWReset, $CPreset, and $UAreset are set earlier in the script with try catch’s so it gives the result of Success or Failed

Hope this helps!


#3

Thanks that helped. So I take it the only way to show results is in a popup (show-UDModal). Shouldn’t be an issue really, but if I end up trying to run these on mobile i’m not sure if it will support it…


#4

Another option:

Set-UDElement -Id “results” -Content { }

That should also do the trick for you, fill in the content you want to present in the brackets and then somewhere on the page use:

New-UDElement -Id “results”

That would define the results you want inside of the New-UDInput -Endpoint

The problem with what you were trying to do is define the New-UDParagraph or Card, etc is that those need a place to display, (Show-UDModal, Set-UDElement, etc)

New-UDinput doesn’t know how to process New-UDParagraph or New-UDCard because those are display elements not action elements (my terms, not official ones).


#5

Thanks Jacob. I’ll give it a try