In short, that goes through the array outputting everything that appears between “CN=” and “,OU=” in each string, then joins it with ‘;’ characters. Feel free to add spaces there or change that for another character or whatever you wanna do.
This is one of those interesting things where the -match operator operates on arrays a bit differently vs single items, so we’re ensuring it gets an array to look at.