Integrate result from a powershell command in a new-UDinput


I would like to see the list of AD groups in the drop-down groups.
For that I would have to insert the results of my powershell command into the UDInput.

Do you have an idea?

New-UDInput -Title "Create new user" -Endpoint {

            $Groups = Get-ADGroup -Filter * | Where-Object {$_.Name -notcontains "GDL*" -and $_.GroupCategory -eq "Security" -and $_.GroupScope -eq "Global"} |
            Format-Table Name -AutoSize
            $password = [System.Web.Security.Membership]::GeneratePassword((Get-Random -Minimum 8 -Maximum 12), 3)
            $securePassword = ConvertTo-SecureString -String $password -AsPlainText -Force

            $NewAdUserParameters = @{
                GivenName = $FirstName
                Surname = $LastName 
                Name = $UserName 
                AccountPassword = $securePassword

            New-AdUser @NewAdUserParameters
            Add-AdGroupMember -Identity $Group -Members $userName

            New-UDInputAction -Content {
                New-UDCard -Title "Temporary Password" -Text $Password
        } -Validate

Thank you!

*Thanks for this script Adam Driscoll =)

I seach a solution and a I have change a thing:

New-UDRow -Columns {
    New-UDColumn -Size 12 -Content {
            $OU1 = Get-ADOrganizationalUnit -LDAPFilter '(name=*)' -SearchBase 'OU=00-Utilisateurs_restreints,OU=00-Utilisateurs,OU=ARMORMECA,DC=armor,DC=meca'  |
            Sort-Object -Property Name | Format-Table Name -AutoSize

        New-UDInput -Title "Reset Password" -SubmitText "Reset Password" -Content {
            New-UDInputField -Name "UserName1" -Placeholder "Account Name" -Type "textbox"
            New-UDInputField -Name "OU1" -Placeholder "OU" -Type "select" -Values "$OU1"
            New-UDInputField -Name "Password1" -Placeholder "Password" -Type "password"

        } -Endpoint {
                $SecurePassword1 = ConvertTo-SecureString $Password1 -AsPlainText -Force
                Set-ADAccountPassword -Reset -NewPassword $SecurePassword1 -Identity $UserName1 @Cache:ConnectionInfo
                New-UDInputAction -Toast "Failed to add user. $_"

the result change:
In the select box i see that :
Microsoft.PowerShell.Commands.Internal.Format.FormatStartData Microsoft.PowerShell.Commands.Internal.Format.GroupStartData


try it like this instead

$OU1 = Get-ADOrganizationalUnit -LDAPFilter '(name=*)' -SearchBase 'OU=00-Utilisateurs_restreints,OU=00-Utilisateurs,OU=ARMORMECA,DC=armor,DC=meca'  |
            Sort-Object -Property Name | Select-Object -ExpandProperty Name

Also try to use another name on the $OU1 variable as its the same as the inputfield generated variable.

1 Like

Good, it’s functionnal.
Thank you.