I'm trying to create a script with GUI that will allow me to create user accounts for my organization and to assign the user accounts to various OUs. My problem is that I want to display a simple name in a listbox and have the selection map to the proper distinguished name for the OU, but to do that I'm having to manually reassign the variables as shown below:
$OU = WPFOU_List.SelectedItems
$WPFHR_Staff.Add_Click({
$WPFOU_List.Items.Clear()
$WPFOU_List.Items.Add("Oregon")
$WPFOU_List.Items.Add("Colorado")
$WPFOU_List.Items.Add("California")
})
$WPFSales_Staff.Add_Click({
$WPFOU_List.Items.Clear()
$WPFOU_List.Items.Add("Portland")
$WPFOU_List.Items.Add("Denver")
$WPFOU_List.Items.Add("Los Angeles")
})
if ($OU = "Oregon")
{$OU = "ou=oregon,ou=hr,dc=my,dc=org,dc=com"}
elseif ($OU = "Colorado")
{$OU = "ou=colorado,ou=hr,dc=my,dc=org,dc=com"}
elseif ($OU = "California")
{$OU = "ou=california,ou=hr,dc=my,dc=org,dc=com"}
elseif ($OU = "Portland")
{$OU = "ou=portland,ou=sales,dc=my,dc=org,dc=com"}
elseif ($OU = "Denver")
{$OU = "ou=denver,ou=sales,dc=my,dc=org,dc=com"}
elseif ($OU = "Los Angeles")
{$OU = "ou=la,ou=sales,dc=my,dc=org,dc=com"}
Clicking either of the buttons populates a listbox with the friendly names, but is there an easier way to map those friendly names to the distinguished paths?