Firstly, when posting code in the forum, please can you use the preformatted text </> button. It really helps us with readability, and copying and pasting your code (we don’t have to faff about replacing curly quote marks to get things working). If you can’t see the </> in your toolbar, you will find it under the gear icon.
Filter the groups with Where-Object.
Split the string for the remaining groups on ‘,OU=’ and select the first element in the array of split strings (element 0).
Remove CN=