ListBox DisplayMember

I currently have a script that works correctly. However, the way it loads is a little hard to read. I am loading AD Groups into a listbox. Currently it shows the FQDN. I need it to show a shortname so that it is easier to read.

$maduname = $mfuser.Text $mfusergroups = Get-ADUser -Identity $maduname -Properties * $mfadrname = $mfusergroups.CN $mfusergroups = $mfusergroups.MemberOf | Sort foreach ($group in $mfusergroups) { $groupstart = $group.IndexOf("=") + 1 $groupend = $group.IndexOf(",") - 3 $mfuseroutbox.Items.Add("$group") }

This is only the small section that needs to be changed.

For terminology’s sale, it is showing DistinguishedName, not FQDN; however, check out this post on the same topic.

https://powershell.org/forums/topic/how-to-extract-only-the-group-name-from-ad-using-powershell-object/#post-31696