For a migration toolkit I wrote, I used a regex with an assertion to split on unescaped commas to break down the distinguished name. I don't know your naming scheme but that's pretty easy to do robustly...
On Nov 2, 2016, at 15:46, Dave Lum <[email protected]<mailto:[email protected]>> wrote: I want to use PowerShell to get the immediate OU a user is in an drop it into said users' description. I can do Set-ADUSer easily enough, I just want to be able to through only the direct OU and not the entire DN into the description. So, instead of 'OU=MyHouse,OU=World,DC=domain,DC=net' I want to just drop in "MyHouse" (the desired description will me "disabled account from myHouse OU". Some "ForEach" thing, right? David Lum Systems Administrator III P: 503.943.2500 E: [email protected]<mailto:[email protected]> A: 1881 SW Naito Parkway, Portland, OR 97201 <image001.png><https://www.facebook.com/OCHINinc><image002.png><https://twitter.com/ochininc><image003.png><http://www.linkedin.com/company/ochin> www.ochin.org<https://www.ochin.org/> <image004.jpg> Attention: Information contained in this message and or attachments is intended only for the recipient(s) named above and may contain confidential and or privileged material that is protected under State or Federal law. If you are not the intended recipient, any disclosure, copying, distribution or action taken on it is prohibited. If you believe you have received this email in error, please contact the sender with a copy to [email protected]<mailto:[email protected]>, delete this email and destroy all copies.

