I wrote a small Forms GUI in Powershell and in there I have a combobox with emails of users from an AD. Now I got an event on SelectedIndexChanged where I want to display more informations about the selected user in a label. Since i have a unique email as a filter there's always just one returned object with Get-ADUser.
My problem is that Get-ADUser returns an array of strings when i use select cn
and even with Out-String
it returns a string with the formatting of a returned array.
I don't want to manually remove the @{cn=}
when i get the returned string. So is there a more effective way to get JUST the value of the returned string array?
This is what I tried:
$label_name.Text = Get-ADUser -Properties mail -Filter {mail -like $comboBox_User.Text} | select cn | Out-String
the returned string looks like this:
cn
-
foo (returned name)
the return i was expecting:
foo