Product: PowerShell Universal
Version: 2.5.4
Hello, not sure if this is a bug or if i’m doing something wrong.
What i’m basically trying to do is provide a transfer list of Users from a OU tree that can be selected.
My Problem is that New-UDTransferList is correctly displaying the first Users in selection “Klasse”, but when i then select a different one it does display nothing.
Her’s a GIF of the Problem.
I’ve read that this or a similar Problem was fixed for 2.5.0, but apparently not for me.
I also tried doing a fresh install with the latest version.
What i discovered that actually does work is if i give New-UDTransferList a random ID with Get-Random within the Dynamic. But now i’m unable to get the selected Items for the -OnSubmit Part of the Form…
Is that normal behavior that New-UDTransferList doesn’t reload when using the same ID?
How can i get the selected Items for my -OnSubmit part of the form? I’ve already tried a few things, but i alwas get an Error Message that the Field “ID” is empty after i press “SUBMIT”
Here’s the Code i’m using:
$Pages += New-UDPage -Name 'Sync setzen' -Content {
$FAs = Get-ADOrganizationalUnit -SearchBase 'OU=Schueler,OU=_KOS,DC=home,DC=test' -SearchScope OneLevel -Filter * -Server $ActiveDirectoryServer -Credential $ActiveDirectoryCredential | Select-Object Name, DistinguishedName
New-UDForm -Content {
New-UDSelect -Id 'selectFA' -Label 'Fachabteilung' -Option {
$FAs | ForEach-Object {New-UDSelectOption -Name $_.Name -Value $_.DistinguishedName}
} -OnChange {Sync-UDElement -Id 'dynSelectClass'}
New-UDDynamic -Id 'dynSelectClass' -Content {
$selectFA = (Get-UDElement -Id 'selectFA').value
if ($selectFA -ne $null)
{
$Classes = Get-ADOrganizationalUnit -SearchBase "$selectFA" -SearchScope OneLevel -Filter * -Server $ActiveDirectoryServer -Credential $ActiveDirectoryCredential | Select-Object Name, DistinguishedName
New-UDSelect -Id 'selectClass' -Label 'Klasse' -Option {
New-UDSelectOption -Name "Bitte wählen" -Value "choosing"
$Classes | ForEach-Object {New-UDSelectOption -Name $_.Name -Value $_.DistinguishedName}
} -OnChange {Sync-UDElement -Id 'dynTest'}
}
}
New-UDDynamic -id 'dynTest' -Content {
$selectClass = (Get-UDElement -Id 'selectClass').Value
if ($selectClass -ne $null -and $selectClass -ne "choosing")
{
$UsersinClass = Get-ADUser -SearchBase $selectClass -Filter * -Properties extensionattribute15 -Server $ActiveDirectoryServer -Credential $ActiveDirectoryCredential | Select-Object Name, DistinguishedName, extensionattribute15
New-UDTransferList -Id 'UserTransferList' -Item {
$UsersinClass | ForEach-Object {if ($_.extensionattribute15 -eq "sync") {New-UDTransferListItem -Name ($_.Name + " (SYNC)") -Value $_.DistinguishedName} else {New-UDTransferListItem -Name $_.Name -Value $_.DistinguishedName}}
}
}
}
} -OnSubmit {
$UserstoSync = (Get-UDElement -Id 'UserTransferList').selecteditem
foreach ($User in $UserstoSync)
{
Set-ADUser -Identity $User.Value -Add @{extensionattribute15="sync"} -Server $ActiveDirectoryServer -Credential $ActiveDirectoryCredential
New-UDTypography -Text "Sync für $($User.Name) gesetzt!"
}
}
}
Thank’s for the Help!